-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Changes from 26 commits
f4b81b7
8b4a5fd
51fdc4f
2ec92cc
7ca5f79
7179dd3
9b13386
b999189
ea22ca4
ce05562
28ac03b
95c50e3
32836b2
f0bdd55
32d7adb
a4b9ae9
0493765
e67ba23
1f8c4bc
f771da3
d72e7ec
8562209
9b99924
92a92bc
95a9140
19efaa8
38fe5bf
24c8201
ac9e742
667efef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,11 @@ | |
import argparse | ||
import logging | ||
import sys | ||
from collections.abc import Sequence | ||
from copy import deepcopy | ||
from functools import partial | ||
from pathlib import Path | ||
from types import TracebackType | ||
from typing import TYPE_CHECKING, Any, cast | ||
from typing import TYPE_CHECKING, cast | ||
|
||
import argcomplete | ||
from decli import cli | ||
|
@@ -48,9 +47,9 @@ def __call__( | |
self, | ||
parser: argparse.ArgumentParser, | ||
namespace: argparse.Namespace, | ||
kwarg: str | Sequence[Any] | None, | ||
kwarg: object, | ||
Lee-W marked this conversation as resolved.
Show resolved
Hide resolved
|
||
option_string: str | None = None, | ||
): | ||
) -> None: | ||
if not isinstance(kwarg, str): | ||
return | ||
if "=" not in kwarg: | ||
|
@@ -550,8 +549,12 @@ def __call__( | |
|
||
|
||
def commitizen_excepthook( | ||
type, value, traceback, debug=False, no_raise: list[int] | None = None | ||
): | ||
type: type[BaseException], | ||
value: BaseException, | ||
traceback: TracebackType | None, | ||
debug: bool = False, | ||
no_raise: list[int] | None = None, | ||
) -> None: | ||
traceback = traceback if isinstance(traceback, TracebackType) else None | ||
if not isinstance(value, CommitizenException): | ||
original_excepthook(type, value, traceback) | ||
|
@@ -581,7 +584,7 @@ def parse_no_raise(comma_separated_no_raise: str) -> list[int]: | |
represents the exit code found in exceptions. | ||
""" | ||
no_raise_items: list[str] = comma_separated_no_raise.split(",") | ||
no_raise_codes = [] | ||
no_raise_codes: list[int] = [] | ||
for item in no_raise_items: | ||
if item.isdecimal(): | ||
no_raise_codes.append(int(item)) | ||
|
@@ -621,7 +624,7 @@ class Args(argparse.Namespace): | |
] | ||
|
||
|
||
def main(): | ||
def main() -> None: | ||
parser: argparse.ArgumentParser = cli(data) | ||
argcomplete.autocomplete(parser) | ||
# Show help if no arg provided | ||
|
@@ -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 commentThe 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., There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. fixed. |
||
|
||
|
||
if __name__ == "__main__": | ||
|
Uh oh!
There was an error while loading. Please reload this page.