workflows icon indicating copy to clipboard operation
workflows copied to clipboard

Lots of python lint errors

Open rasa opened this issue 1 year ago • 2 comments

Would you consider a PR that addresses these issues? Are there any issues you'd prefer not be quieted?

mypy

  tests/test_changelog.py: note: In function "test_changelog_update":
  tests/test_changelog.py:86: error: Function is missing a type annotation  [no-untyped-def]
  gha_utils/metadata.py:228: error: Missing type parameters for generic type "dict"  [type-arg]
  gha_utils/metadata.py: note: In function "is_python_project":
  gha_utils/metadata.py:604: error: Function is missing a return type annotation  [no-untyped-def]
  gha_utils/metadata.py: note: In member "is_python_project" of class "Metadata":
  gha_utils/metadata.py:604: error: Function is missing a return type annotation  [no-untyped-def]
  gha_utils/metadata.py:613: error: Function is missing a return type annotation  [no-untyped-def]
  gha_utils/metadata.py: note: In member "package_name" of class "Metadata":
  gha_utils/metadata.py:644: error: Returning Any from function declared to return "str | None"  [no-any-return]
  gha_utils/metadata.py: note: In member "dump" of class "Metadata":
  gha_utils/metadata.py:1210: error: "type[Dialects]" has no attribute "PLAIN"  [attr-defined]
  gha_utils/cli.py: note: In function "prep_path":
  gha_utils/cli.py:52: error: Missing type parameters for generic type "IO"  [type-arg]
  gha_utils/cli.py: note: In function "gha_utils":
  gha_utils/cli.py:99: error: Function is missing a return type annotation  [no-untyped-def]
  gha_utils/cli.py:99: note: Use "-> None" if function does not return a value
  gha_utils/cli.py: note: In function "metadata":
  gha_utils/cli.py:124: error: Function is missing a type annotation  [no-untyped-def]
  gha_utils/cli.py: note: In function "changelog":
  gha_utils/cli.py:182: error: Function is missing a type annotation  [no-untyped-def]
  gha_utils/cli.py: note: In function "mailmap_sync":
  gha_utils/cli.py:223: error: Function is missing a type annotation  [no-untyped-def]
  gha_utils/__main__.py: note: In function "main":
  gha_utils/__main__.py:26: error: Function is missing a return type annotation  [no-untyped-def]
  gha_utils/__main__.py:26: note: Use "-> None" if function does not return a value
  gha_utils/__main__.py: note: At top level:
  gha_utils/__main__.py:49: error: Call to untyped function "main" in typed context  [no-untyped-call]
  Found 14 errors in 4 files (checked 8 source files)

pyright

  /github/workspace/gha_utils/__main__.py
    /github/workspace/gha_utils/__main__.py:45:15 - error: No parameter named "prog_name" (reportCallIssue)
  /github/workspace/gha_utils/cli.py
    /github/workspace/gha_utils/cli.py:26:6 - warning: Import "click_extra" could not be resolved (reportMissingImports)
  /github/workspace/gha_utils/metadata.py
    /github/workspace/gha_utils/metadata.py:124:6 - warning: Import "pyproject_metadata" could not be resolved (reportMissingImports)
    /github/workspace/gha_utils/metadata.py:125:6 - warning: Import "wcmatch.glob" could not be resolved (reportMissingImports)
    /github/workspace/gha_utils/metadata.py:1204:40 - error: Cannot access attribute "PLAIN" for class "type[Dialects]"
      Attribute "PLAIN" is unknown (reportAttributeAccessIssue)
  /github/workspace/tests/test_changelog.py
    /github/workspace/tests/test_changelog.py:21:8 - warning: Import "pytest" could not be resolved (reportMissingImports)
  2 errors, 4 warnings, 0 informations 

pylint

  ************* Module gha_utils.__main__
  gha_utils/__main__.py:43:4: C0415: Import outside toplevel (gha_utils.cli.gha_utils) (import-outside-toplevel)
  ************* Module gha_utils.changelog
  gha_utils/changelog.py:1:0: C0114: Missing module docstring (missing-module-docstring)
  gha_utils/changelog.py:40:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/changelog.py:43:4: C0116: Missing function or method docstring (missing-function-docstring)
  gha_utils/changelog.py:46:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/changelog.py:49:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/changelog.py:113:8: C0103: Variable name "SECTION_START" doesn't conform to '[a-z_][a-z0-9_]*$' pattern (invalid-name)
  gha_utils/changelog.py:120:8: C0103: Variable name "DATE_REGEX" doesn't conform to '[a-z_][a-z0-9_]*$' pattern (invalid-name)
  gha_utils/changelog.py:121:8: C0103: Variable name "VERSION_REGEX" doesn't conform to '[a-z_][a-z0-9_]*$' pattern (invalid-name)
  gha_utils/changelog.py:145:8: W1201: Use lazy % formatting in logging functions (logging-not-lazy)
  ************* Module gha_utils.cli
  gha_utils/cli.py:1:0: C0114: Missing module docstring (missing-module-docstring)
  gha_utils/cli.py:58:4: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:64:4: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:71:12: R1724: Unnecessary "else" after "continue", remove the "else" and de-indent the code inside it (no-else-continue)
  gha_utils/cli.py:84:4: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:89:0: C0116: Missing function or method docstring (missing-function-docstring)
  gha_utils/cli.py:114:18: W0622: Redefining built-in 'format' (redefined-builtin)
  gha_utils/cli.py:142:4: W0621: Redefining name 'metadata' from outer scope (line 114) (redefined-outer-name)
  gha_utils/cli.py:130:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:132:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:172:0: C0116: Missing function or method docstring (missing-function-docstring)
  gha_utils/cli.py:178:4: W0621: Redefining name 'changelog' from outer scope (line 172) (redefined-outer-name)
  gha_utils/cli.py:175:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:185:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:187:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:235:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:239:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:245:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:246:8: W1201: Use lazy % formatting in logging functions (logging-not-lazy)
  gha_utils/cli.py:252:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/cli.py:254:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  ************* Module gha_utils.mailmap
  gha_utils/mailmap.py:1:0: C0114: Missing module docstring (missing-module-docstring)
  gha_utils/mailmap.py:61:28: R1734: Consider using [] instead of list() (use-list-literal)
  gha_utils/mailmap.py:75:15: C1802: Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty (use-implicit-booleaness-not-len)
  gha_utils/mailmap.py:88:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/mailmap.py:133:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/mailmap.py:134:18: W1510: 'subprocess.run' used without explicitly defining the value for 'check'. (subprocess-run-check)
  gha_utils/mailmap.py:143:8: W1201: Use lazy % formatting in logging functions (logging-not-lazy)
  gha_utils/mailmap.py:157:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/mailmap.py:160:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  ************* Module gha_utils.metadata
  gha_utils/metadata.py:967:13: W0511: XXX We consider here the module is directly callable, because Nuitka (fixme)
  gha_utils/metadata.py:1027:17: W0511: XXX "-X utf8" parameter is a workaround for Windows runners (fixme)
  gha_utils/metadata.py:118:0: C0413: Import "from bumpversion.config import get_configuration" should be placed at the top of the module (wrong-import-position)
  gha_utils/metadata.py:119:0: C0413: Import "from bumpversion.config.files import find_config_file" should be placed at the top of the module (wrong-import-position)
  gha_utils/metadata.py:120:0: C0413: Import "from bumpversion.show import resolve_name" should be placed at the top of the module (wrong-import-position)
  gha_utils/metadata.py:121:0: C0413: Import "from packaging.specifiers import SpecifierSet" should be placed at the top of the module (wrong-import-position)
  gha_utils/metadata.py:122:0: C0413: Import "from packaging.version import Version" should be placed at the top of the module (wrong-import-position)
  gha_utils/metadata.py:123:0: C0413: Import "from pydriller import Commit, Git, Repository" should be placed at the top of the module (wrong-import-position)
  gha_utils/metadata.py:124:0: C0413: Import "from pyproject_metadata import ConfigurationError, StandardMetadata" should be placed at the top of the module (wrong-import-position)
  gha_utils/metadata.py:125:0: C0413: Import "from wcmatch.glob import BRACE, DOTGLOB, FOLLOW, GLOBSTAR, GLOBTILDE, NEGATE, NODIR, iglob" should be placed at the top of the module (wrong-import-position)
  gha_utils/metadata.py:287:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:280:4: R6301: Method could be a function (no-self-use)
  gha_utils/metadata.py:360:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:367:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:372:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:377:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:385:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:388:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:402:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:489:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:595:4: C0116: Missing function or method docstring (missing-function-docstring)
  gha_utils/metadata.py:613:12: W0104: Statement seems to have no effect (pointless-statement)
  gha_utils/metadata.py:691:12: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:837:4: R0914: Too many local variables (19/15) (too-many-locals)
  gha_utils/metadata.py:1080:16: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
  gha_utils/metadata.py:1188:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:1189:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:1207:8: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
  gha_utils/metadata.py:227:0: R0904: Too many public methods (36/20) (too-many-public-methods)
  ************* Module tests.test_changelog
  tests/test_changelog.py:1:0: C0114: Missing module docstring (missing-module-docstring)
  tests/test_changelog.py:85:0: C0116: Missing function or method docstring (missing-function-docstring)

rasa avatar Sep 26 '24 05:09 rasa

Thanks for being so thorough!

Baseline is: ruff is always right. I choose to ditch all other linters but mypy and ruff to not waste time reconciling multiple opinions from multiple linters. Because of the law of diminished returns, rules become opinions.

That's why I don't want to see any ignore or configuration statement for anything but mypy and ruff. Still, you can propose changes informed by pyright and pylint.

BTW, which version of each linter are you using? Are these the last versions?

mypy

I'm surprised by the mypy errors you reported, because I also run it with every commit and no errors have been reported: https://github.com/kdeldycke/workflows/actions/runs/11047175581/job/30688000739#step:7:1

Anyway, any improvement in adding typing where I explicitly ignored them is welcome. Most of the time I added # type: ignore statement because I was too lazy or tired to go the extra mile (perfect is the enemy of shipped).

pyright

could not be resolved issue is because pyright doesn't seems to see the project dependencies for whatever reason.

pylint

  • R0914: Too many local variables: this is a matter of opinion. Maybe there is no need to over-split the code at this location.
  • W1203: Use lazy % formatting: yeah, that's basically noise. This project is small enough for this kind of micro-optimization to not matter. But if you feel like it, I'm OK with merging changes to %s-based logging.

kdeldycke avatar Sep 26 '24 07:09 kdeldycke

@kdeldycke Linters should all be reasonably up to date, and are listed in https://github.com/rasa/workflows/actions/runs/11044502120/job/30680530531#step:5:184

mypy: v1.11.1 pyright: v1.1.376 (latest is v1.1.382) pylint: v3.2.6

using these settings:

mypy: .mypy.ini pyright: .pyrightconfig-loose.json pylint: .pylintrc

I think I will quiet most of this noise on my end. Based on your feedback, I may submit a PR for things that make sense to fix on your end.

rasa avatar Sep 27 '24 02:09 rasa