Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Lucas Cimon
Lucas Cimon

Posted on

Pylint strict base configuration

Pylint is a great static code analyser for Python code.
I have been using it for several years, in various projects, and it's simple to use yet very powerful.

I even contributed to Pylint by submitting a new rule a few years ago :implicit-str-concat.

For an introduction to Pylint, you can check those tutorials:

Pylint default configuration is very reasonable, but one thing that I find missing is a simple way to switch to a "strict" mode, that would enable all optional rules. ESLint haseslint-config-strict-mode for example.

Such "strict" mode can be useful:

  • when bootstrapping a new project, you may want to enable all rules by default,
    and progressively disable the ones you find non necessary for your project

  • on an existing project using Pylint, when you want to test what extra checks
    can be performed by this tool, and see if it can spot bugs you missed so far

The following.pylintrc configuration file is my attempt to setup a "strict" mode:

[MESSAGESCONTROL]# Enable some checkers that are not activated by default:enable=bad-inline-option,deprecated-pragma,file-ignored,use-symbolic-message-instead,useless-suppression# Include some helpful details on errors messages for naming rules:include-naming-hint=yes[MASTER]# Informational messages ("I") should make Pylint execution fail (non-0 program return code):fail-on=I# Enable many optional extensions:load-plugins=pylint.extensions.bad_builtin,pylint.extensions.code_style,pylint.extensions.comparison_placement,pylint.extensions.consider_refactoring_into_while_condition,pylint.extensions.docparams,pylint.extensions.dunder,pylint.extensions.eq_without_hash,pylint.extensions.for_any_all,pylint.extensions.magic_value,pylint.extensions.mccabe,pylint.extensions.no_self_use,pylint.extensions.overlapping_exceptions,pylint.extensions.private_import,pylint.extensions.redefined_loop_name,pylint.extensions.redefined_variable_type,pylint.extensions.set_membership,pylint.extensions.typing,pylint.extensions.while_used,[STRING_CONSTANT]# Doc: https://pylint.pycqa.org/en/latest/user_guide/messages/warning/implicit-str-concat.htmlcheck-quote-consistency=yes[VARIABLES]allow-global-unused-variables=no
Enter fullscreen modeExit fullscreen mode

I recently used this approach onfpdf2:PR #780 Hardening Pylint config

Related configuration files infpdf2:

I hope this.pylintrc could be useful to others!

You can drop a comment if this article was helpful to you 😊

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Hi, I'm a French software engineer🔭 I’m currently a DevOps tech lead at sncf-connect.com✨ Some of my games are on itch.io🐍 I ❤️ Python: I'm the maintainer of fpdf2 and a few pre-commit hooks
  • Location
    Nantes, France
  • Work
    Software Engineer & Technical lead at oui.sncf
  • Joined

More fromLucas Cimon

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp