Skip to content

Commit

Permalink
Update types for mypy 1.7 (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Nov 13, 2023
1 parent b7bafb1 commit 5064f4e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ repos:
args: ["-L", "sur,nd"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.6.1"
rev: "v1.7.0"
hooks:
- id: mypy
files: "^traitlets"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Tracker = "https://github.com/ipython/traitlets/issues"
[project.optional-dependencies]
test = [
"argcomplete>=3.0.3",
"mypy>=1.6.0",
"mypy>=1.7.0",
"pre-commit",
"pytest-mock",
"pytest-mypy-testing",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class T(HasTraits):
t = T()
reveal_type(List(["foo"])) # R: traitlets.traitlets.List[builtins.str]
reveal_type(List([""]).tag(sync=True)) # R: traitlets.traitlets.List[builtins.str]
reveal_type(List(None, allow_none=True)) # R: traitlets.traitlets.List[<nothing>]
reveal_type(List(None, allow_none=True)) # R: traitlets.traitlets.List[Never]
reveal_type(
List(None, allow_none=True).tag(sync=True) # R: traitlets.traitlets.List[<nothing>]
List(None, allow_none=True).tag(sync=True) # R: traitlets.traitlets.List[Never]
)
reveal_type(T.latex_command) # R: traitlets.traitlets.List[builtins.str]
reveal_type(t.latex_command) # R: builtins.list[builtins.str]
Expand Down
6 changes: 3 additions & 3 deletions traitlets/config/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
IS_PYTHONW = sys.executable and sys.executable.endswith("pythonw.exe")

T = t.TypeVar("T", bound=t.Callable[..., t.Any])
AnyLogger = t.Union[logging.Logger, logging.LoggerAdapter]
AnyLogger = t.Union[logging.Logger, "logging.LoggerAdapter[t.Any]"]
StrDict = t.Dict[str, t.Any]
ArgvType = t.Optional[t.List[str]]
ClassesType = t.List[t.Type[Configurable]]
Expand Down Expand Up @@ -713,12 +713,12 @@ def initialize_subcommand(self, subc: str, argv: ArgvType = None) -> None:
self.subapp = subapp.instance(parent=self)
elif callable(subapp):
# or ask factory to create it...
self.subapp = subapp(self) # type:ignore[call-arg]
self.subapp = subapp(self)
else:
raise AssertionError("Invalid mappings for subcommand '%s'!" % subc)

# ... and finally initialize subapp.
self.subapp.initialize(argv) # type:ignore[union-attr]
self.subapp.initialize(argv)

def flatten_flags(self) -> tuple[dict[str, t.Any], dict[str, t.Any]]:
"""Flatten flags and aliases for loaders, so cl-args override as expected.
Expand Down
6 changes: 3 additions & 3 deletions traitlets/config/argcomplete_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_argcomplete_cwords() -> t.Optional[t.List[str]]:
cword_suffix,
comp_words,
last_wordbreak_pos,
) = argcomplete.split_line(comp_line, comp_point) # type:ignore[attr-defined]
) = argcomplete.split_line(comp_line, comp_point) # type:ignore[attr-defined,no-untyped-call]
except ModuleNotFoundError:
return None

Expand Down Expand Up @@ -73,7 +73,7 @@ def increment_argcomplete_index() -> None:
os.environ["_ARGCOMPLETE"] = str(int(os.environ["_ARGCOMPLETE"]) + 1)
except Exception:
try:
argcomplete.debug("Unable to increment $_ARGCOMPLETE", os.environ["_ARGCOMPLETE"]) # type:ignore[attr-defined]
argcomplete.debug("Unable to increment $_ARGCOMPLETE", os.environ["_ARGCOMPLETE"]) # type:ignore[attr-defined,no-untyped-call]
except (KeyError, ModuleNotFoundError):
pass

Expand Down Expand Up @@ -196,7 +196,7 @@ def _get_completions(
# Instead, check if comp_words only consists of the script,
# if so check if any subcommands start with cword_prefix.
if self.subcommands and len(comp_words) == 1:
argcomplete.debug("Adding subcommands for", cword_prefix) # type:ignore[attr-defined]
argcomplete.debug("Adding subcommands for", cword_prefix) # type:ignore[attr-defined,no-untyped-call]
completions.extend(subc for subc in self.subcommands if subc.startswith(cword_prefix))

return completions
Expand Down

0 comments on commit 5064f4e

Please sign in to comment.