Skip to content

Commit

Permalink
Adjust configuration mypy
Browse files Browse the repository at this point in the history
The strict flag enables the following flags (the precise list
depends on the mypy version, see mypy --help):

  --warn-unused-configs,
  --disallow-any-generics,
  --disallow-subclassing-any,
  --disallow-untyped-calls,
  --disallow-untyped-defs,
  --disallow-incomplete-defs,
  --check-untyped-defs,
  --disallow-untyped-decorators,
  --warn-redundant-casts,
  --warn-unused-ignores,
  --warn-return-any,
  --no-implicit-reexport,
  --strict-equality,
  --extra-checks

This means mypy accepts the following code as valid:

```
import typing

def ignore_without_code() -> int:
    return "a"  # type: ignore

def redundant_expr(x: int) -> int:
    return 1 if isinstance(x, int) else 2

def possible_undefined(x: int) -> int:
    if x > 0:
        result = 1
    return result

def any_explicit(_x: typing.Any) -> None:
    pass

def any_expr() -> None:
    a = x  # type: ignore[name-defined]
```
  • Loading branch information
SoloJacobs committed Jul 25, 2024
1 parent 3140291 commit cd212d3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ build-backend = "poetry.core.masonry.api"

[tool.mypy]
strict = true
enable_error_code = [
"ignore-without-code",
"redundant-expr",
"possibly-undefined",
]
disallow_any_expr = true
disallow_any_explicit = true


[tool.isort]
profile = "black"

0 comments on commit cd212d3

Please sign in to comment.