Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Pylint RC file #1256

Closed
dhermes opened this issue Dec 1, 2015 · 7 comments
Closed

Update Pylint RC file #1256

dhermes opened this issue Dec 1, 2015 · 7 comments
Assignees

Comments

@dhermes
Copy link
Contributor

dhermes commented Dec 1, 2015

@tseaver After running

pylint --generate-rcfile

I curated the output to mostly match ours and made a simple diff:

diff --git a/pylintrc_default b/pylintrc_default
index 27c4b5d..72bb922 100644
--- a/pylintrc_default
+++ b/pylintrc_default
@@ -19,9 +19,6 @@
 # pygtk.require().
 # DEFAULT: init-hook=

-# Profiled execution.
-# DEFAULT:  profile=no
-
 # Add files or directories to the blacklist. They should be base names, not
 # paths.
 # DEFAULT:  ignore=CVS
@@ -42,15 +39,33 @@ ignore =
 #            they document.
 load-plugins=pylint.extensions.check_docs

-# DEPRECATED
-# DEFAULT:  include-ids=no
+# Use multiple processes to speed up Pylint.
+jobs=1
+
+# Allow loading of arbitrary C extensions. Extensions are imported into the
+# active Python interpreter and may run arbitrary code.
+unsafe-load-any-extension=no
+
+# A comma-separated list of package or module names from where C extensions may
+# be loaded. Extensions are loading into the active Python interpreter and may
+# run arbitrary code
+extension-pkg-whitelist=

-# DEPRECATED
-# DEFAULT:  symbols=no
+# Allow optimization of some AST trees. This will activate a peephole AST
+# optimizer, which will apply various small optimizations. For instance, it can
+# be used to obtain the result of joining multiple strings with the addition
+# operator. Joining a lot of strings can lead to a maximum recursion error in
+# Pylint and this flag can prevent that. It has one side effect, the resulting
+# AST will be different than the one from reality.
+optimize-ast=no


 [MESSAGES CONTROL]

+# Only show warnings with the listed confidence levels. Leave empty to show
+# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
+confidence=
+
 # Enable the message, report, category or checker with the given id(s). You can
 # either give multiple identifier separated by comma (,) or put this option
 # multiple time. See also the "--disable" option for examples.
@@ -120,13 +135,9 @@ reports=no
 # (RP0004).
 # DEFAULT:  evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)

-# Add a comment according to your evaluation note. This is used by the global
-# evaluation report (RP0004).
-# DEFAULT:  comment=no
-
 # Template used to display messages. This is a python new-style format string
 # used to format the message information. See doc for all details
-#msg-template=
+# DEFAULT:  msg-template=


 [SIMILARITIES]
@@ -157,6 +168,27 @@ reports=no
 # you should avoid to define new builtins when possible.
 # DEFAULT:  additional-builtins=

+# List of strings which can identify a callback function by name. A callback
+# name must start or end with one of those strings.
+callbacks=cb_,_cb
+
+
+[SPELLING]
+
+# Spelling dictionary name. Available dictionaries: none. To make it working
+# install python-enchant package.
+spelling-dict=
+
+# List of comma separated words that should not be checked.
+spelling-ignore-words=
+
+# A path to a file that contains private dictionary; one word per line.
+spelling-private-dict-file=
+
+# Tells whether to store unknown words to indicated private dictionary in
+# --spelling-private-dict-file option instead of raising a message.
+spelling-store-unknown-words=no
+

 [LOGGING]

@@ -168,7 +200,7 @@ reports=no
 [FORMAT]

 # Maximum number of characters on a single line.
-# DEFAULT:  max-line-length=80
+max-line-length=100

 # Regexp for a line that is allowed to be longer than the limit.
 # DEFAULT:  ignore-long-lines=^\s*(# )?<?https?://\S+>?$
@@ -198,6 +230,9 @@ max-module-lines=1500
 # Number of spaces of indent required inside a hanging or continued line.
 # DEFAULT:  indent-after-paren=4

+# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
+expected-line-ending-format=
+

 [MISCELLANEOUS]

@@ -207,15 +242,12 @@ max-module-lines=1500

 [BASIC]

-# Required attributes for module, separated by a comma
-# DEFAULT:  required-attributes=
-
 # List of builtins function names that should not be used, separated by a comma
 # DEFAULT:  bad-functions=map,filter,apply,input,file

 # Good variable names which should always be accepted, separated by a comma
 # DEFAULT:  good-names=i,j,k,ex,Run,_
-# RATIONALE:  'pb' and 'id' have well-understood meainings in the code.
+# RATIONALE:  'pb' and 'id' have well-understood meanings in the code.
 good-names = i, j, k, ex, Run, _,
              pb,
              id,
@@ -292,13 +324,19 @@ good-names = i, j, k, ex, Run, _,

 # Regular expression which should only match function or class names that do
 # not require a docstring.
-# DEFAULT:  no-docstring-rgx=__.*__
+no-docstring-rgx=^_

 # Minimum line length for functions/classes that require docstrings, shorter
 # ones are exempt.
 # DEFAULT:  docstring-min-length=-1


+[ELIF]
+
+# Maximum number of nested blocks for function / method body
+max-nested-blocks=5
+
+
 [TYPECHECK]

 # Tells whether missing members accessed in mixin class should be ignored. A
@@ -307,21 +345,19 @@ good-names = i, j, k, ex, Run, _,

 # List of module names for which member attributes should not be checked
 # (useful for modules/projects where namespaces are manipulated during runtime
-# and thus existing member attributes cannot be deduced by static analysis
+# and thus existing member attributes cannot be deduced by static analysis. It
+# supports qualified module names, as well as Unix pattern matching.
 # DEFAULT:  ignored-modules=

 # List of classes names for which member attributes should not be checked
-# (useful for classes with attributes dynamically set).
-# DEFAULT:  ignored-classes=SQLObject
-
-# When zope mode is activated, add a predefined set of Zope acquired attributes
-# to generated-members.
-# DEFAULT:  zope=no
+# (useful for classes with attributes dynamically set). This supports can work
+# with qualified names.
+ignored-classes=

 # List of members which are set dynamically and missed by pylint inference
-# system, and so shouldn't trigger E0201 when accessed. Python regular
+# system, and so shouldn't trigger E1101 when accessed. Python regular
 # expressions are accepted.
-# DEFAULT:  generated-members=REQUEST,acl_users,aq_parent
+generated-members=


 [IMPORTS]
@@ -344,10 +380,6 @@ good-names = i, j, k, ex, Run, _,

 [CLASSES]

-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-# DEFAULT:  ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
-
 # List of method names used to declare (i.e. assign) instance attributes.
 # DEFAULT:  defining-attr-methods=__init__,__new__,setUp

@@ -357,6 +389,10 @@ good-names = i, j, k, ex, Run, _,
 # List of valid names for the first argument in a metaclass class method.
 # DEFAULT:  valid-metaclass-classmethod-first-arg=mcs

+# List of member names, which should be excluded from the protected access
+# warning.
+exclude-protected=_asdict,_fields,_replace,_source,_make
+

 [DESIGN]

@@ -400,6 +436,9 @@ min-public-methods=0
 # RATIONALE:  API mapping
 max-public-methods=40

+# Maximum number of boolean expressions in a if statement
+max-bool-expr=5
+

 [EXCEPTIONS]

Some things worth noting

  • the default list of disabled went from empty to include 50 things
  • max line length went from 80 to 100 (but AFAIK it's 79 in the pep8 defaults)
  • adding [MASTER].jobs to speed up execution (happy, happy)
  • a [SPELLING] section was enabled for spellcheck (via python-enchant)
  • [FORMAT].expected-line-ending-format added (so we can disallow Windows line endings)
@dhermes dhermes added the hygiene label Dec 1, 2015
@dhermes
Copy link
Contributor Author

dhermes commented Dec 1, 2015

@tseaver Can you inspect the diff and comment on things we should take advantage of?

@dhermes
Copy link
Contributor Author

dhermes commented Dec 9, 2015

@tseaver Bump

@tseaver
Copy link
Contributor

tseaver commented Dec 9, 2015

  • The new commented out defaults are fine.
  • Definitely not OK with bumping max-line-length above 80 chars.
  • I thought we were already requiring docstrings even for private methods / functions / classes, but would be fine with dropping that requirement.
  • max-nested-blocks and max-bool-expr look arbitrarily low: if it doesn't cause a barf on current code, we can leave it be.
  • Are the new values for exclude-protected based on our usage, or just defaults?

@dhermes
Copy link
Contributor Author

dhermes commented Dec 10, 2015

  • Thanks
  • max-line-length=100 is strange to me
  • I prefer docstrings everywhere, since it helps other people understand our thoughts
  • I didn't try the new config yet (or at least don't remember if I did) so can't speak on the barf
  • RE: exclude-protected, these are just values from pylint --generate-rcfile

  • What about expected-line-ending-format for Unix only? w00t
  • Are you not excited by jobs=1?

@tseaver
Copy link
Contributor

tseaver commented Dec 11, 2015

max-line-length=100 is strange to me

Violates PEP8.

I prefer docstrings everywhere, since it helps other people understand our thoughts

I think the "full-court press" docstring style (intended to generate Sphinx markup) is less than helpful for non-API methods (which I don't think should be in Sphinx, either).

I didn't try the new config yet (or at least don't remember if I did) so can't speak on the barf

I'm definitely against introducing new dogmatic opinions without testing their impact first.

What about expected-line-ending-format for Unix only? w00t

If we ever get Windows contributors, we'll need to allow them to run the linter without barfing on their own machines. Maybe do this check only in Travis, and document that they need to use `core.autocrlf'.

Are you not excited by jobs=1?

Not much point in 1. :)

a [SPELLING] section was enabled for spellcheck (via python-enchant)

I'm not a big fan, especially given that we'd need to be checking in the dictionary.

@dhermes
Copy link
Contributor Author

dhermes commented Dec 14, 2015

Not much point in 1

I just meant the feature. We should crank it up to 11.

@dhermes
Copy link
Contributor Author

dhermes commented Dec 14, 2015

I'll send one or two PRs with slow updates to the new defaults (and I'll re-org the sections to match the new output order so future diffs aren't difficult).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants