Skip to content

Commit

Permalink
🔧 Upgrade mypy and config (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo committed Mar 26, 2024
1 parent 4c051bc commit c1dd661
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
6 changes: 0 additions & 6 deletions mypy.ini

This file was deleted.

14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ all = [

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

[tool.isort]
profile = "black"
Expand All @@ -75,6 +76,19 @@ filterwarnings = [
'ignore::DeprecationWarning:xdist',
]

[tool.mypy]
strict = true

[[tool.mypy.overrides]]
module = "docs_src.*"
disallow_incomplete_defs = false
disallow_untyped_defs = false
disallow_untyped_calls = false

[[tool.mypy.overrides]]
module = "shellingham"
ignore_missing_imports = true

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
Expand Down
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pytest-cov >=2.10.0,<5.0.0
coverage[toml] >=6.2,<7.0
pytest-xdist >=1.32.0,<4.0.0
pytest-sugar >=0.9.4,<0.10.0
mypy ==0.971
mypy ==1.4.1
ruff ==0.2.0
4 changes: 2 additions & 2 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ set -e
set -x

mypy typer
ruff typer tests docs_src scripts
ruff format typer tests --check
ruff typer tests docs_src
ruff format typer tests docs_src --check
13 changes: 7 additions & 6 deletions typer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ def compat_autocompletion(

out = []

for c in autocompletion(ctx, [], incomplete): # type: ignore
for c in autocompletion(ctx, [], incomplete):
if isinstance(c, tuple):
c = CompletionItem(c[0], help=c[1])
elif isinstance(c, str):
c = CompletionItem(c)
use_completion = CompletionItem(c[0], help=c[1])
else:
assert isinstance(c, str)
use_completion = CompletionItem(c)

if c.value.startswith(incomplete):
out.append(c)
if use_completion.value.startswith(incomplete):
out.append(use_completion)

return out

Expand Down
8 changes: 4 additions & 4 deletions typer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def except_hook(
else:
stack.append(frame)
# Type ignore ref: https://github.com/python/typeshed/pull/8244
final_stack_summary = StackSummary.from_list(stack) # type: ignore
final_stack_summary = StackSummary.from_list(stack)
tb_exc.stack = final_stack_summary
for line in tb_exc.format():
print(line, file=sys.stderr)
Expand Down Expand Up @@ -685,7 +685,7 @@ def wrapper(**kwargs: Any) -> Any:
use_params[k] = v
if context_param_name:
use_params[context_param_name] = click.get_current_context()
return callback(**use_params) # type: ignore
return callback(**use_params)

update_wrapper(wrapper, callback)
return wrapper
Expand Down Expand Up @@ -998,7 +998,7 @@ def wrapper(ctx: click.Context, param: click.Parameter, value: Any) -> Any:
else:
use_value = value
use_params[value_name] = use_value
return callback(**use_params) # type: ignore
return callback(**use_params)

update_wrapper(wrapper, callback)
return wrapper
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def wrapper(ctx: click.Context, args: List[str], incomplete: Optional[str]) -> A
use_params[args_name] = args
if incomplete_name:
use_params[incomplete_name] = incomplete
return callback(**use_params) # type: ignore
return callback(**use_params)

update_wrapper(wrapper, callback)
return wrapper
Expand Down

0 comments on commit c1dd661

Please sign in to comment.