commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

Turn on mypy check_untyped_defs = true

Open Lee-W opened this issue 1 year ago • 2 comments

Description

mypy keeps warning us to use check_untyped_defs. When turning it on, I found out there're a few type annotation issues that could be improved and could potentially be an actual issue.


Possible Solution

Fix the type annotation error/warning one by one

Additional context

list of modules needed to be fixed by 3.21.3

  • [ ] commitizen/config/yaml_config.py
  • [ ] commitizen/commands/init.py
  • [ ] commitizen/config/toml_config.py
  • [ ] commitizen/config/json_config.py
  • [x] commitizen/cz/base.py
  • [ ] tests/test_factory.py
  • [ ] commitizen/commands/changelog.py
  • [x] commitizen/commands/example.py
  • [ ] commitizen/commands/commit.py
  • [ ] commitizen/git.py
  • [ ] tests/test_changelog.py
  • [x] commitizen/cli.py
  • [ ] tests/test_cz_customize.py
  • [ ] tests/test_cz_conventional_commits.py
  • [ ] tests/test_cz_base.py
  • [ ] commitizen/commands/info.py
  • [x] commitizen/commands/check.py

Additional context

No response

Lee-W avatar Apr 04 '24 10:04 Lee-W

Possible configurations, commented ones raise new errors to resolve:

--- a/pyproject.toml
+++ b/pyproject.toml
@@ -171,12 +171,19 @@ convention = "google"
 
 [tool.mypy]
 files = "commitizen"
-disallow_untyped_decorators = true
+# check_untyped_defs = true # TODO
+# disallow_any_generics = true # TODO
+# disallow_incomplete_defs = true # TODO
 disallow_subclassing_any = true
-warn_return_any = true
+# disallow_untyped_calls = true # TODO
+disallow_untyped_decorators = true
+# disallow_untyped_defs = true # TODO
+no_implicit_optional = true
+strict_equality = true
 warn_redundant_casts = true
-warn_unused_ignores = true
+warn_return_any = true
 warn_unused_configs = true
+warn_unused_ignores = true

AdrianDC avatar Aug 22 '24 00:08 AdrianDC

Sounds like a good idea!

Lee-W avatar Aug 22 '24 03:08 Lee-W