Browse Source

chore: update mypy and move to toml (#547)

* Updates mypy to 0.950
* Uses pyproject.toml insted of mypy.ini - nicer config, fewer files
* Uses `strict = true` instead of the long list (supported last few versions)
* Uses more precise include ignoring, and includes a couple of typing requirements
    * Exposes a variable type change, fixed
* Adds a few extra (easy) strictness and config flags. Didn't add unreachable, since it was more involved.

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
pull/549/head
Henry Schreiner 3 months ago committed by GitHub
parent
commit
6da5d33194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .pre-commit-config.yaml
  2. 1
      MANIFEST.in
  3. 17
      mypy.ini
  4. 4
      packaging/requirements.py
  5. 10
      pyproject.toml

3
.pre-commit-config.yaml

@ -8,11 +8,12 @@ repos:
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
rev: v0.950
hooks:
- id: mypy
exclude: '^(docs|tasks|tests)|setup\.py'
args: []
additional_dependencies: [pyparsing, nox]
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0

1
MANIFEST.in

@ -4,7 +4,6 @@ include LICENSE LICENSE.APACHE LICENSE.BSD
include .coveragerc
include .flake8
include .pre-commit-config.yaml
include mypy.ini
recursive-include docs *
recursive-include tests *.py

17
mypy.ini

@ -1,17 +0,0 @@
[mypy]
ignore_missing_imports = True
# The following are the flags enabled by --strict
warn_unused_configs = True
disallow_subclassing_any = True
disallow_any_generics = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
no_implicit_reexport = True

4
packaging/requirements.py

@ -20,7 +20,7 @@ from pyparsing import ( # noqa
stringStart,
)
from .markers import MARKER_EXPR, Marker
from .markers import MARKER_EXPR as _MARKER_EXPR, Marker
from .specifiers import LegacySpecifier, Specifier, SpecifierSet
@ -66,7 +66,7 @@ _VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or "")
VERSION_SPEC = originalTextFor(_VERSION_SPEC)("specifier")
VERSION_SPEC.setParseAction(lambda s, l, t: t[1])
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
MARKER_EXPR = originalTextFor(_MARKER_EXPR())("marker")
MARKER_EXPR.setParseAction(
lambda s, l, t: Marker(s[t._original_start : t._original_end])
)

10
pyproject.toml

@ -1,3 +1,13 @@
[build-system]
requires = ['setuptools >= 40.8.0', 'wheel']
build-backend = 'setuptools.build_meta'
[tool.mypy]
strict = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
[[tool.mypy.overrides]]
module = ["_manylinux"]
ignore_missing_imports = true

Loading…
Cancel
Save