-
-
Notifications
You must be signed in to change notification settings - Fork 286
refactor: improve types and avoid nested loop, add types for untyped functions #1466
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
base: refactors
Are you sure you want to change the base?
refactor: improve types and avoid nested loop, add types for untyped functions #1466
Conversation
eb74027
to
5013472
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## refactors #1466 +/- ##
=============================================
+ Coverage 97.82% 97.87% +0.05%
=============================================
Files 57 57
Lines 2619 2683 +64
=============================================
+ Hits 2562 2626 +64
Misses 57 57
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mypy
warnings
dda979c
to
6bfa0e4
Compare
6bfa0e4
to
f882f67
Compare
commitizen/commands/changelog.py
Outdated
src = Path(tpl.filename) | ||
Path(self.export_template_to).write_text(src.read_text()) | ||
src = Path(tpl.filename) # type: ignore | ||
Path(self.export_template_to).write_text(src.read_text()) # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be fixed. tpl.filename
is str | None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a TODO comment then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also created an issue. This can probably be good first?
f882f67
to
b136173
Compare
3e41480
to
fe0ae1a
Compare
fe0ae1a
to
d5010d8
Compare
mypy
warningsmypy
warnings
d5010d8
to
49b596e
Compare
mypy
warningsfca731b
to
f8e56ab
Compare
441837d
to
1f8c4bc
Compare
18c260a
to
8562209
Compare
fa9382b
to
95a9140
Compare
commitizen/cli.py
Outdated
@@ -676,7 +679,7 @@ def main(): | |||
) | |||
sys.excepthook = no_raise_debug_excepthook | |||
|
|||
args.func(conf, arguments)() | |||
args.func(conf, arguments)() # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it needed? could we try to narrow it a bit e.g., type: ignore[call-args]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me check. Maybe we don't need this after #1479
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commitizen/cli.py:682: error: Argument 2 to "Commit" has incompatible type "dict[str, Any]"; expected "CommitArgs" [arg-type]
commitizen/cli.py:682: error: Argument 2 to "Bump" has incompatible type "dict[str, Any]"; expected "BumpArgs" [arg-type]
commitizen/cli.py:682: error: Argument 2 to "Changelog" has incompatible type "dict[str, Any]"; expected "ChangelogArgs" [arg-type]
commitizen/cli.py:682: error: Argument 2 to "Check" has incompatible type "dict[str, Any]"; expected "CheckArgs" [arg-type]
commitizen/cli.py:682: error: Argument 2 to "Version" has incompatible type "dict[str, Any]"; expected "VersionArgs" [arg-type]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, let's add it 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly good, 2 nitpicks. will merge it later today
commitizen/commands/bump.py
Outdated
self.changelog_flag = bool( | ||
self.changelog_flag or self.changelog_to_stdout or self.changelog_config | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.changelog_flag = bool( | |
self.changelog_flag or self.changelog_to_stdout or self.changelog_config | |
) | |
self.changelog_flag = any( | |
[self.changelog_flag, self.changelog_to_stdout, self.changelog_config] | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Description
possible_tags
aset[str]
to avoid linear-time search for each candidate tag.Sequence
tolist
) and make the parameter type as abstract as possible (e.g. fromlist
toSequence
orIterable
)smart_open
.# type: ignore
to bypassmypy
check. We can address those potential errors in the future?cast
also for bypassingmypy
check.ruff
rules more strict.commands
.Note that I didn't run
mypy --disallow-untyped-defs tests/
because typingtests/
does not help much for development.Before (4b6b3fb)
Very long error messages after running mypy
After
Checklist
Code Changes
poetry all
locally to ensure this change passes linter check and tests