Skip to main content

Pylint extension with good practices and code smell detection

Project description

pylint-plus

Latest Version License

Pylint plugin with good practices extensions

Running

This is a pylint plugin, so for running it you will need to load the plugin.

➜ pylint --load-plugins pylint_plus my_source_code.py 

Checkers

This plugin implements several checkers.

Magic constant

before

This checker detects magic constants in code. Magic constants are a code smell and should be replaced by meaningful named constants.

example.py

"""Example file"""
def method_return_magic_constant():
    """Example method"""
    return 42

when running lint would yield

▶ pylint --load-plugins=pylint_plus example.py
************* Module test
test.py:4:11: R1001: Magic constant found (magic-constant)

------------------------------------------------------------------
Your code has been rated at 5.00/10 (previous run: 5.00/10, +0.00)

after

"""Example file"""
UNIVERSE_ULTIMATE_QUESTION_ANSWER = 42

def method_return_magic_constant():
    """Example method"""
    return UNIVERSE_ULTIMATE_QUESTION_ANSWER

running lint again yields

▶ pylint --load-plugins=pylint_plus example.py

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Configuration

You may tweak the checker to be more or less strict. For this checker, we have the following options available.

Option Result
allow-return-constants Allow returning constants
allow-compare-constants Allow comparing constants
allow-binary-constants Allow binary operation with constants
allow-call-args-constants Allow call args to be constants
allow-subscript-constants Allow subscript args to be constants
allow-int-constants Ignore int constants
allow-str-constants Ignore string constants
allow-float-constants Ignore float constants

Boolean types are ignored by this checker.

Return method

TO BE DOCUMENTED

Function/Method order

TO BE DOCUMENTED

You may find other examples at the example/ directory

Changelog

v0.0.2

  • Initial implementation of the Function/Method order checker.
  • Fix Return Method checker unit tests

v0.0.1

  • Initial implementation of the Magic constant checker.
  • Initial implementation of the Return method checker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylint-plus-0.0.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylint_plus-0.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pylint-plus-0.0.2.tar.gz.

File metadata

  • Download URL: pylint-plus-0.0.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for pylint-plus-0.0.2.tar.gz
Algorithm Hash digest
SHA256 43ae5b410abdbb90b4743a18378256d988b0437d3c51f9d3d827037079b65bc8
MD5 ca19020cea77b6dddea362e00c150c4a
BLAKE2b-256 2cfaaaebc33b9203d56bf726dba772ee2538ede1d1e56321db7a2f59694fae51

See more details on using hashes here.

File details

Details for the file pylint_plus-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pylint_plus-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for pylint_plus-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ca5424556d778400d52e9fe6be88afbbcc38b7514a71d853d522da6c5e1c783f
MD5 476c376581964f3c3d8cfb67ed71d2fb
BLAKE2b-256 68073b1cc394e194f46b2c8746bd68fcbc6387434f9ad6cc244b71c24e4ce0da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page