Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

azure-pylint-guidelines-checker

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

azure-pylint-guidelines-checker

A pylint plugin which enforces azure sdk guidelines.

  • 0.0.8
  • PyPI
  • Socket score

Maintainers
2

Linting the Guidelines

The code presented in this repository is a lift-and-shift of code originally written by @kristapratico

Running guidelines checks in Azure/azure-sdk-for-python repository

In order to lint for the guidelines, you must make sure you are enabling the pylint-guidelines-checker in your pylint invocation. Using the rcfile at the root of the repo will ensure that the plugin is properly activated

It is recommended you run pylint at the library package level to be consistent with how the CI runs pylint.

Check that you are running pylint version >=2.14.5 and astroid version >=2.12.0.

  1. Install the pylint checker from the azure-sdk development feed.

    pip install --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/" pylint-guidelines-checker
    
  2. Run pylint at the root of the repo and it will automatically find the pylintrc:

    C:\azure-sdk-for-python>pylint sdk/storage/azure-storage-blob/azure
    
  3. Add the --rcfile command line argument with a relative path to the pylintrc from your current directory:

    C:\azure-sdk-for-python\sdk\storage>pylint --rcfile="../../pylintrc" azure-storage-blob
    
  4. Set the environment variable PYLINTRC to the absolute path of the pylintrc file:

    set PYLINTRC=C:\azure-sdk-for-python\pylintrc
    

    Run pylint:

    C:\azure-sdk-for-python\sdk\storage>pylint azure-storage-blob
    
  5. Run pylint at the package level using tox and it will find the pylintrc file:

    pip install tox tox-monorepo
    C:\azure-sdk-for-python\sdk\storage\azure-storage-blob>tox -e lint -c ../../../eng/tox/tox.ini
    
  6. If you use the pylint extension for VS code or Pycharm it should find the pylintrc automatically.

How to disable a pylint error

# pylint:disable=connection-string-should-not-be-constructor-param

The pylint custom checkers for SDK guidelines fall into messages range C4717 - C4738. You will know you came across a custom checker if it contains a link to the guidelines.

In the case of a false positive, use the disable command to remove the pylint error.

Rules List

Pylint checker nameHow to fix thisHow to disable this ruleLink to python guideline
client-method-should-not-use-static-methodUse module level functions instead.# pylint:disable=client-method-should-not-use-static-methodlink
missing-client-constructor-parameter-credentialAdd a credential parameter to the client constructor. Do not use plural form "credentials".# pylint:disable=missing-client-constructor-parameter-credentiallink
missing-client-constructor-parameter-kwargsAdd a **kwargs parameter to the client constructor.# pylint:disable=missing-client-constructor-parameter-kwargslink
client-method-has-more-than-5-positional-argumentsUse keyword arguments to reduce number of positional arguments.# pylint:disable=client-method-has-more-than-5-positional-argumentslink
client-method-missing-type-annotationsCheck that param/return type comments are present or that param/return type annotations are present. Check that you did not mix type comments with type annotations.# pylint:disable=client-method-missing-type-annotationslink
client-incorrect-naming-conventionCheck that you use... snake_case for variable, function, and method names. Pascal case for types. ALL CAPS for constants.# pylint:disable=client-incorrect-naming-conventionlink
client-method-missing-kwargsCheck that any methods that make network calls have a **kwargs parameter.# pylint:disable=client-method-missing-kwargslink
config-missing-kwargs-in-policyCheck that the policies in your configuration function contain a **kwargs parameter.# pylint:disable=config-missing-kwargs-in-policylink
async-client-bad-nameRemove "Async" from your service client's name.# pylint:disable=async-client-bad-namelink
file-needs-copyright-headerAdd a copyright header to the top of your file.# pylint:disable=file-needs-copyright-headerlink
client-method-name-no-double-underscoreDon't use method names prefixed with "__".# pylint:disable=client-method-name-no-double-underscorelink
specify-parameter-names-in-callSpecify the parameter names when calling methods with more than 2 required positional parameters. e.g. self.get_foo(one, two, three=three, four=four, five=five)# pylint:disable=specify-parameter-names-in-calllink
connection-string-should-not-be-constructor-paramRemove connection string parameter from client constructor. Create a method that creates the client using a connection string.# pylint:disable=connection-string-should-not-be-constructor-paramlink
package-name-incorrectChange your distribution package name to only include dashes, e.g. azure-storage-file-share# pylint:disable=package-name-incorrectlink
client-suffix-neededService client types should use a "Client" suffix, e.g. BlobClient.# pylint:disable=client-suffix-neededlink
docstring-admonition-needs-newlineAdd a blank newline above the .. literalinclude statement.# pylint:disable=docstring-admonition-needs-newlineNo guideline, just helps our docs get built correctly for microsoft docs.
naming-mismatchDo not alias models imported from the generated code.# pylint:disable=naming-mismatchlink
client-accepts-api-version-keywordEnsure that the client constructor accepts a keyword-only api_version argument.# pylint:disable=client-accepts-api-version-keywordlink
enum-must-be-uppercaseThe enum name must be all uppercase.# pylint:disable=enum-must-be-uppercaselink
enum-must-inherit-case-insensitive-enum-metaThe enum should inherit from CaseInsensitiveEnumMeta.# pylint:disable=enum-must-inherit-case-insensitive-enum-metalink
networking-import-outside-azure-core-transportThis import is only allowed in azure.core.pipeline.transport.# pylint:disable=networking-import-outside-azure-core-transportlink
non-abstract-transport-importOnly import abstract transports. Let core or end-user decide which transport to use.# pylint:disable=non-abstract-transport-importlink
no-raise-with-tracebackCheck that raise_with_traceback from azure-core is replaced with python 3 'raise from' syntax.# pylint:disable=no-raise-with-tracebacklink
name-too-longCheck that the length of class names, function names, and variable names are under 40 characters.# pylint:disable=name-too-longlink
delete-operation-wrong-return-typeCheck that delete* or begin_delete* methods return None or LROPoller[None].# pylint:disable=delete-operation-wrong-return-typelink
client-method-missing-tracing-decoratorpylint:disable=client-method-missing-tracing-decoratorCheck that sync client methods that make network calls have the sync distributed tracing decorator.link
client-method-missing-tracing-decorator-asyncpylint:disable=client-method-missing-tracing-decorator-asyncCheck that async client methods that make network calls have the async distributed tracing decorator.link

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc