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

introduce strict-ish pylint + minimal fixes #98

Merged
merged 59 commits into from
Aug 3, 2023
Merged

introduce strict-ish pylint + minimal fixes #98

merged 59 commits into from
Aug 3, 2023

Commits on Aug 2, 2023

  1. pylintrc: add initial default .pylintrc

    Generated via `pylint --generate-rcfile`
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    6411bba View commit details
    Browse the repository at this point in the history
  2. pylintrc: set max-line-length=88

    Consistent with `black` formatter.
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    b8ba28a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e4d6ed3 View commit details
    Browse the repository at this point in the history
  4. pylintrc: fix unqualified exception names

    PyLint 2.16 has started complaining:
    > pylint: Command line or configuration file:1: UserWarning: Specifying
    > exception names in the overgeneral-exceptions option without module
    > name is deprecated and support for it will be removed in pylint 3.0.
    > Use fully qualified name (maybe 'builtins.BaseException' ?) instead.
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    5a34385 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    969aed7 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    89179de View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    b34892f View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    7a222b1 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    7a58d97 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    7a77c25 View commit details
    Browse the repository at this point in the history
  11. pylintrc: enable all extensions and minimum initial suppressions

    The checks will be selectively removed from "disabled=…" as fixed.
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    789f958 View commit details
    Browse the repository at this point in the history
  12. pylint: suppress 'arguments-differ' on python 3.8 and 3.9

    The type declaration of Generic.__new__ is over-broad in Python 3.8
    (likely also in 3.9, though not verified), but fixed in later versions.
    
    This causes warnings if `Generic` subclasses override `__new__` but
    don't expose an "anything goes" (*args, **kwargs) signature.
    
    It's not worth writing a specialized transformer to fix it, and it's
    lame to have to write lint suppressions on correct code, especially when
    it only applies to a particular version.
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    56affb2 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    a1a1892 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    4f73592 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    8b56c64 View commit details
    Browse the repository at this point in the history
  16. lint: remove redundant 'pass' statements

    pylint: unnecessary-pass
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    f96c18a View commit details
    Browse the repository at this point in the history
  17. lint: enable fixme checker

    Suppressing two existing TODOs in rxelems.test
    
    pylint: fixme
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    2f5abe0 View commit details
    Browse the repository at this point in the history
  18. lint: enable comparison-with-itself

    Suppressed in intentional `__eq__` tests.
    
    pylint: comparison-with-itself
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    5eb6f60 View commit details
    Browse the repository at this point in the history
  19. lint: enable too-many-public-methods checker

    Suppressing on Fsm class.
    
    pylint: too-many-public-methods
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    8168bd9 View commit details
    Browse the repository at this point in the history
  20. lint: enable too-many-* checkers

    Suppressing on existing large functions.
    
    pylint: too-many-branches
    pylint: too-many-locals
    pylint: too-many-return-statements
    pylint: too-many-statements
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    9097cf0 View commit details
    Browse the repository at this point in the history
  21. lint: enable compare-to-empty-string checker

    Suppressed in tests where it's actually checking string output.
    
    > Avoid comparisons to empty string
    
    pylint: compare-to-empty-string
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    99986dc View commit details
    Browse the repository at this point in the history
  22. lint: enable unused variable checker

    pylint: unused-variable
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    12e8128 View commit details
    Browse the repository at this point in the history
  23. lint: fix trivial pointless-statement/expression-not-assigned

    pylint: expression-not-assigned
    pylint: pointless-statement
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    2da3134 View commit details
    Browse the repository at this point in the history
  24. lint: tests: suppress protected-access on ._commonconc

    > Access to a protected member _commonconc of a client class
    
    pylint: protected-access
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    861e5fa View commit details
    Browse the repository at this point in the history
  25. lint: "x not in" vs. "not x in"

    > test for membership should be 'not in'
    
    flake8: E713
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    8cdd1b9 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    31221fe View commit details
    Browse the repository at this point in the history
  27. lint: avoid unnecessary-comprehension warning

    pylint: unnecessary-comprehension
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    d46e704 View commit details
    Browse the repository at this point in the history
  28. lint: use [] instead of list()

    > consider using [] instead of list()
    
    pylint: use-list-literal
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    0add7cc View commit details
    Browse the repository at this point in the history
  29. lint: rewrite list(…) == [] as not list(…)

    >> 'list(...) != []' can be simplified to 'list(...)' as an empty
    >> sequence is falsey
    
    pylint: use-implicit-booleaness-not-comparison
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    86062b0 View commit details
    Browse the repository at this point in the history
  30. lint: rewrite len(x) > 0 as x; len(x) == 0 as not x

    > Avoid comparisons to zero
    
    pylint: compare-to-zero
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    60fd7d3 View commit details
    Browse the repository at this point in the history
  31. lint: write x in y or x in z as x in (y, z)

    pylint: consider-using-in
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    06a5dc5 View commit details
    Browse the repository at this point in the history
  32. lint: fix else: if:elif:

    > Consider using "elif" instead of "else" then "if" to remove one
    > indentation level
    
    pylint: else-if-used
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    ff70825 View commit details
    Browse the repository at this point in the history
  33. lint: fix unnecessary lambda str: len(str) lambda

    This was also a shadowed outer name, since `str` is a variable in the
    outer scope.
    
    pylint: unnecessary-lambda
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    9439be7 View commit details
    Browse the repository at this point in the history
  34. lint: remove some unused fixture arguments in fsm_test

    pylint: unused-argument
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    da3c74d View commit details
    Browse the repository at this point in the history
  35. lint: fix shadowed functions/locals/args

    > Redefining name 'static' from outer scope
    
    pylint: redefined-outer-name
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    6f234dc View commit details
    Browse the repository at this point in the history
  36. lint: avoid shadowing min/max builtin names

    pylint: redefined-builtin
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    13f72bc View commit details
    Browse the repository at this point in the history
  37. lint: avoid shadowing input builtin where possible

    pylint: redefined-builtin
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    f1cdd28 View commit details
    Browse the repository at this point in the history
  38. lint: avoid shadowing map builtin name where possible

    To avoid altering signatures, this does not include keyword arguments or
    attributes of `Fsm` here, just local variable names.
    
    >  Redefining built-in 'map'
    
    pylint: redefined-builtin
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    edad9d9 View commit details
    Browse the repository at this point in the history
  39. lint: unshadow next builtin name

    pylint: redefined-builtin
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    c9b7302 View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    1967468 View commit details
    Browse the repository at this point in the history
  41. lint: iterating over .keys() is redundant

    pylint: consider-iterating-dictionary
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    7a0b10a View commit details
    Browse the repository at this point in the history
  42. lint: fsm: avoid redundant lookup to transition map

    Note that there are many other instances of unnecessary lookups; this is
    the only one that triggers this checker.
    
    pylint: unnecessary-dict-index-lookup
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    d2c4c9b View commit details
    Browse the repository at this point in the history
  43. lint: iterate over .items() vs. keys + lookup

    pylint: consider-using-dict-items
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    663667f View commit details
    Browse the repository at this point in the history
  44. lint: use enumerate() vs range+len

    > Consider using enumerate instead of iterating with range and len
    
    pylint: consider-using-enumerate
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    89e5ba9 View commit details
    Browse the repository at this point in the history
  45. lint: simplify dict creation via dict literals

    > Consider using a dictionary comprehension
    
    pylint: consider-using-dict-comprehension
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    a38f0e6 View commit details
    Browse the repository at this point in the history
  46. lint: use comprehension vs filter builtin

    > Used builtin function 'filter'. Using a list comprehension can be
    > clearer.
    
    pylint: bad-builtin
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    6f88a75 View commit details
    Browse the repository at this point in the history
  47. lint: fix redefined-variable-type warnings

    > Redefinition of initial type from set to frozenset
    > Redefinition of mults type from list to reversed
    
    pylint: redefined-variable-type
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    55ab660 View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    26dcecd View commit details
    Browse the repository at this point in the history
  49. lint: fix or suppress invalid-name style warnings

    Trying to keep it low-ish impact.
    
    pylint: invalid-name
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    8ecc8a0 View commit details
    Browse the repository at this point in the history
  50. nit: charclass.__repr__: avoid useless str(char)/key=str in sorted ch…

    …arset
    
    The collection already contains `str` elements.
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    9829ea7 View commit details
    Browse the repository at this point in the history
  51. lint: charclass: more consistent use of f-strings

    > Formatting a regular string which could be a f-string
    
    pylint: consider-using-f-string
    rwe committed Aug 2, 2023
    Configuration menu
    Copy the full SHA
    1a7c1d5 View commit details
    Browse the repository at this point in the history

Commits on Aug 3, 2023

  1. lint: simplify a couple ternary-able expressions

    > Consider rewriting as a ternary expression
    
    pylint: consider-ternary-expression
    rwe committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    079ad78 View commit details
    Browse the repository at this point in the history
  2. lint: avoid redefining loop variables

    > Redefining 'symbol' from loop
    
    pylint: redefined-loop-name
    rwe committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    924413d View commit details
    Browse the repository at this point in the history
  3. lint: explicitly define "cannot __hash__" on Fsm

    > Implementing __eq__ without also implementing __hash__
    
    pylint: eq-without-hash
    rwe committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    967a48c View commit details
    Browse the repository at this point in the history
  4. lint: rewrite a couple for loops as any()

    > `for` loop could be `any(…)`
    
    pylint: consider-using-any-or-all
    rwe committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    3468455 View commit details
    Browse the repository at this point in the history
  5. lint: reduce some overlarge try/except statement groups

    > try clause contains 9 statements, expected at most 1
    
    pylint: too-many-try-statements
    rwe committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    551c13f View commit details
    Browse the repository at this point in the history
  6. lint: raise more specific errors and enable broad-exception-raised

    > Raising too general exception: Exception
    
    pylint: broad-exception-raised
    rwe committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    1670052 View commit details
    Browse the repository at this point in the history
  7. pylintrc: set typevar name regex

    rwe committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    24a2e8a View commit details
    Browse the repository at this point in the history
  8. lint: remove some useless suppressions

    And enables the `useless-suppression` checker, which is disabled by
    default.
    
    Removes some statements which would not trigger warnings, for some
    reason or other: generally these are left over from refactors.
    
    For example, the too-many-arguments on `Fsm.__init__` had been
    triggering before the arguments were explicitly marked as keyword-only,
    but the suppression was not removed with that change.
    
    pylint: useless-suppression
    rwe committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    c4faa1b View commit details
    Browse the repository at this point in the history