Skip to content

Commit c1dd661

Browse files
authored
🔧 Upgrade mypy and config (#768)
1 parent 4c051bc commit c1dd661

File tree

6 files changed

+28
-19
lines changed

6 files changed

+28
-19
lines changed

mypy.ini

-6
This file was deleted.

pyproject.toml

+14
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ all = [
5050

5151
[tool.pdm]
5252
version = { source = "file", path = "typer/__init__.py" }
53+
distribution = true
5354

5455
[tool.isort]
5556
profile = "black"
@@ -75,6 +76,19 @@ filterwarnings = [
7576
'ignore::DeprecationWarning:xdist',
7677
]
7778

79+
[tool.mypy]
80+
strict = true
81+
82+
[[tool.mypy.overrides]]
83+
module = "docs_src.*"
84+
disallow_incomplete_defs = false
85+
disallow_untyped_defs = false
86+
disallow_untyped_calls = false
87+
88+
[[tool.mypy.overrides]]
89+
module = "shellingham"
90+
ignore_missing_imports = true
91+
7892
[tool.ruff.lint]
7993
select = [
8094
"E", # pycodestyle errors

requirements-tests.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pytest-cov >=2.10.0,<5.0.0
55
coverage[toml] >=6.2,<7.0
66
pytest-xdist >=1.32.0,<4.0.0
77
pytest-sugar >=0.9.4,<0.10.0
8-
mypy ==0.971
8+
mypy ==1.4.1
99
ruff ==0.2.0

scripts/lint.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -e
44
set -x
55

66
mypy typer
7-
ruff typer tests docs_src scripts
8-
ruff format typer tests --check
7+
ruff typer tests docs_src
8+
ruff format typer tests docs_src --check

typer/core.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ def compat_autocompletion(
7777

7878
out = []
7979

80-
for c in autocompletion(ctx, [], incomplete): # type: ignore
80+
for c in autocompletion(ctx, [], incomplete):
8181
if isinstance(c, tuple):
82-
c = CompletionItem(c[0], help=c[1])
83-
elif isinstance(c, str):
84-
c = CompletionItem(c)
82+
use_completion = CompletionItem(c[0], help=c[1])
83+
else:
84+
assert isinstance(c, str)
85+
use_completion = CompletionItem(c)
8586

86-
if c.value.startswith(incomplete):
87-
out.append(c)
87+
if use_completion.value.startswith(incomplete):
88+
out.append(use_completion)
8889

8990
return out
9091

typer/main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def except_hook(
9595
else:
9696
stack.append(frame)
9797
# Type ignore ref: https://github.com/python/typeshed/pull/8244
98-
final_stack_summary = StackSummary.from_list(stack) # type: ignore
98+
final_stack_summary = StackSummary.from_list(stack)
9999
tb_exc.stack = final_stack_summary
100100
for line in tb_exc.format():
101101
print(line, file=sys.stderr)
@@ -685,7 +685,7 @@ def wrapper(**kwargs: Any) -> Any:
685685
use_params[k] = v
686686
if context_param_name:
687687
use_params[context_param_name] = click.get_current_context()
688-
return callback(**use_params) # type: ignore
688+
return callback(**use_params)
689689

690690
update_wrapper(wrapper, callback)
691691
return wrapper
@@ -998,7 +998,7 @@ def wrapper(ctx: click.Context, param: click.Parameter, value: Any) -> Any:
998998
else:
999999
use_value = value
10001000
use_params[value_name] = use_value
1001-
return callback(**use_params) # type: ignore
1001+
return callback(**use_params)
10021002

10031003
update_wrapper(wrapper, callback)
10041004
return wrapper
@@ -1051,7 +1051,7 @@ def wrapper(ctx: click.Context, args: List[str], incomplete: Optional[str]) -> A
10511051
use_params[args_name] = args
10521052
if incomplete_name:
10531053
use_params[incomplete_name] = incomplete
1054-
return callback(**use_params) # type: ignore
1054+
return callback(**use_params)
10551055

10561056
update_wrapper(wrapper, callback)
10571057
return wrapper

0 commit comments

Comments
 (0)