Title: refactor: improve types and avoid nested loop, add types for untyped functions by bearomorphism · Pull Request #1466 · commitizen-tools/commitizen · GitHub
Open Graph Title: refactor: improve types and avoid nested loop, add types for untyped functions by bearomorphism · Pull Request #1466 · commitizen-tools/commitizen
X Title: refactor: improve types and avoid nested loop, add types for untyped functions by bearomorphism · Pull Request #1466 · commitizen-tools/commitizen
Description: Description Performance improvement: make possible_tags a set[str] to avoid linear-time search for each candidate tag. Types: make the return type more strict (e.g. from Sequence to list) and make the parameter type as abstract as possible (e.g. from list to Sequence or Iterable) Add types for all untyped functions except smart_open. Added some # type: ignore to bypass mypy check. We can address those potential errors in the future? Added some cast also for bypassing mypy check. Make some methods protected. Make ruff rules more strict. Add types for dictionary arguments in commands. Note that I didn't run mypy --disallow-untyped-defs tests/ because typing tests/ does not help much for development. Before (4b6b3fb) Very long error messages after running mypy commitizen-py3.13➜ commitizen git:(master) mypy commitizen/ tests/ commitizen/config/base_config.py:10: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/config/base_config.py:12: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/exceptions.py:45: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:96: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:98: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:100: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:101: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:102: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:104: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:114: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:115: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:116: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:141: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:142: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/changelog.py:164: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/changelog.py:165: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/changelog.py:168: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/changelog.py:229: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] Success: no issues found in 109 source files commitizen-py3.13➜ commitizen git:(master) mypy --disallow-untyped-defs commitizen commitizen/out.py:11: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/out.py:16: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/out.py:36: error: Function is missing a return type annotation [no-untyped-def] commitizen/config/base_config.py:9: error: Function is missing a return type annotation [no-untyped-def] commitizen/config/base_config.py:9: note: Use "-> None" if function does not return a value commitizen/config/base_config.py:10: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/config/base_config.py:12: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/config/base_config.py:22: error: Function is missing a type annotation [no-untyped-def] commitizen/providers/base_provider.py:32: error: Function is missing a return type annotation [no-untyped-def] commitizen/providers/base_provider.py:61: error: Function is missing a return type annotation [no-untyped-def] commitizen/providers/base_provider.py:69: error: Function is missing a return type annotation [no-untyped-def] commitizen/providers/base_provider.py:82: error: Function is missing a return type annotation [no-untyped-def] commitizen/providers/base_provider.py:90: error: Function is missing a return type annotation [no-untyped-def] commitizen/providers/poetry_provider.py:18: error: Function is missing a return type annotation [no-untyped-def] commitizen/providers/commitizen_provider.py:14: error: Function is missing a return type annotation [no-untyped-def] commitizen/providers/cargo_provider.py:31: error: Function is missing a return type annotation [no-untyped-def] commitizen/exceptions.py:43: error: Function is missing a type annotation [no-untyped-def] commitizen/exceptions.py:45: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/exceptions.py:53: error: Function is missing a type annotation [no-untyped-def] commitizen/exceptions.py:60: error: Function is missing a type annotation [no-untyped-def] commitizen/cmd.py:31: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/git.py:39: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/git.py:46: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/git.py:63: error: Function is missing a return type annotation [no-untyped-def] commitizen/git.py:66: error: Function is missing a type annotation [no-untyped-def] commitizen/git.py:71: error: Function is missing a type annotation [no-untyped-def] commitizen/git.py:76: error: Function is missing a type annotation [no-untyped-def] commitizen/git.py:80: error: Function is missing a return type annotation [no-untyped-def] commitizen/git.py:163: error: Function is missing a return type annotation [no-untyped-def] commitizen/git.py:291: error: Function is missing a type annotation [no-untyped-def] commitizen/cz/base.py:79: error: Function is missing a return type annotation [no-untyped-def] commitizen/hooks.py:9: error: Function is missing a type annotation [no-untyped-def] commitizen/config/yaml_config.py:20: error: Function is missing a return type annotation [no-untyped-def] commitizen/config/yaml_config.py:20: note: Use "-> None" if function does not return a value commitizen/config/yaml_config.py:44: error: Function is missing a type annotation [no-untyped-def] commitizen/config/toml_config.py:20: error: Function is missing a return type annotation [no-untyped-def] commitizen/config/toml_config.py:20: note: Use "-> None" if function does not return a value commitizen/config/toml_config.py:33: error: Function is missing a type annotation [no-untyped-def] commitizen/config/json_config.py:19: error: Function is missing a return type annotation [no-untyped-def] commitizen/config/json_config.py:19: note: Use "-> None" if function does not return a value commitizen/config/json_config.py:23: error: Function is missing a type annotation [no-untyped-def] commitizen/cz/utils.py:9: error: Function is missing a type annotation [no-untyped-def] commitizen/cz/utils.py:15: error: Function is missing a type annotation [no-untyped-def] commitizen/changelog.py:66: error: Function is missing a return type annotation [no-untyped-def] commitizen/changelog.py:66: note: Use "-> None" if function does not return a value commitizen/changelog.py:166: error: Function is missing a return type annotation [no-untyped-def] commitizen/changelog.py:221: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/providers/scm_provider.py:26: error: Function is missing a return type annotation [no-untyped-def] commitizen/cz/conventional_commits/conventional_commits.py:12: error: Function is missing a type annotation [no-untyped-def] commitizen/cz/conventional_commits/conventional_commits.py:23: error: Function is missing a type annotation [no-untyped-def] commitizen/commands/list_cz.py:9: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/list_cz.py:12: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/list_cz.py:12: note: Use "-> None" if function does not return a value commitizen/commands/schema.py:8: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/schema.py:12: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/schema.py:12: note: Use "-> None" if function does not return a value commitizen/commands/init.py:82: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/init.py:88: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/init.py:88: note: Use "-> None" if function does not return a value commitizen/commands/init.py:210: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/init.py:305: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/init.py:326: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/init.py:372: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/info.py:8: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/info.py:12: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/info.py:12: note: Use "-> None" if function does not return a value commitizen/commands/example.py:8: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/example.py:12: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/example.py:12: note: Use "-> None" if function does not return a value commitizen/commands/commit.py:95: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/commit.py:95: note: Use "-> None" if function does not return a value commitizen/commands/commit.py:96: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:98: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:100: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:101: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:102: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:104: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:114: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:115: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:116: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:141: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/commit.py:142: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/check.py:20: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/check.py:51: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/check.py:51: note: Use "-> None" if function does not return a value commitizen/commands/check.py:64: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/check.py:64: note: Use "-> None" if function does not return a value commitizen/commands/check.py:100: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/version.py:13: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/version.py:19: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/version.py:19: note: Use "-> None" if function does not return a value commitizen/commands/changelog.py:31: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/commands/changelog.py:135: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/changelog.py:153: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/changelog.py:153: note: Use "-> None" if function does not return a value commitizen/commands/changelog.py:158: error: Function is missing a return type annotation [no-untyped-def] commitizen/commands/changelog.py:164: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/changelog.py:165: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/changelog.py:168: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/commands/changelog.py:229: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked] commitizen/cli.py:47: error: Function is missing a return type annotation [no-untyped-def] commitizen/cli.py:552: error: Function is missing a return type annotation [no-untyped-def] commitizen/cli.py:552: error: Function is missing a type annotation for one or more arguments [no-untyped-def] commitizen/cli.py:598: error: Function is missing a return type annotation [no-untyped-def] commitizen/cli.py:598: note: Use "-> None" if function does not return a value Found 71 errors in 28 files (checked 57 source files) After commitizen-py3.13➜ commitizen git:(better-type) mypy commitizen/ tests/ Success: no issues found in 110 source files commitizen-py3.13➜ commitizen git:(better-type) mypy --disallow-untyped-defs commitizen Success: no issues found in 57 source files Checklist I have read the contributing guidelines Code Changes Add test cases to all the changes you introduce Run poetry all locally to ensure this change passes linter check and tests Manually test the changes: Verify the feature/bug fix works as expected in real-world scenarios Test edge cases and error conditions Ensure backward compatibility is maintained Document any manual testing steps performed Update the documentation for the changes
Open Graph Description: Description Performance improvement: make possible_tags a set[str] to avoid linear-time search for each candidate tag. Types: make the return type more strict (e.g. from Sequence to list) and make...
X Description: Description Performance improvement: make possible_tags a set[str] to avoid linear-time search for each candidate tag. Types: make the return type more strict (e.g. from Sequence to list) and make...
Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1466
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:a77d4acc-f003-4d67-29ce-f67c9b2e3c5b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 97D2:1D90CC:4C02EDF:6BB9F38:6A4FD38C |
| html-safe-nonce | 4f7771f0ae9e1163bf34e86e44a67134a3f468fb442eaa3851b40d71069db36b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0QyOjFEOTBDQzo0QzAyRURGOjZCQjlGMzg6NkE0RkQzOEMiLCJ2aXNpdG9yX2lkIjoiMjI1Mjk4OTQwNTQ0NTczOTQwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f67f1a1647f5999539161c817103f4d7f9ea1d6969138e7a8abaa8592301893f |
| hovercard-subject-tag | pull_request:2552335240 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/commitizen-tools/commitizen/pull/1466/files |
| twitter:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| og:image:alt | Description Performance improvement: make possible_tags a set[str] to avoid linear-time search for each candidate tag. Types: make the return type more strict (e.g. from Sequence to list) and make... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19b98c3d9767bb8a56238a89ff8401d1cbdf3bc5c353799aacf49fe6c76b4b7c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 142593e66413bbae27fd485859993597d5a3b104 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width