Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check types with mypy #7622

Merged
merged 3 commits into from Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Expand Up @@ -2,6 +2,9 @@ name: Lint

on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1

permissions:
contents: read

Expand Down Expand Up @@ -46,3 +49,6 @@ jobs:
run: tox -e lint
env:
PRE_COMMIT_COLOR: always

- name: Mypy
run: tox -e mypy
32 changes: 31 additions & 1 deletion pyproject.toml
Expand Up @@ -94,7 +94,6 @@ test-command = "cd {project} && .github/workflows/wheels-test.sh"
test-extras = "tests"

[tool.ruff]
line-length = 88
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle errors
Expand Down Expand Up @@ -125,3 +124,34 @@ known-first-party = ["PIL"]
[tool.pytest.ini_options]
addopts = "-ra --color=yes"
testpaths = ["Tests"]

[tool.mypy]
python_version = "3.8"
pretty = true
disallow_any_generics = true
enable_error_code = "ignore-without-code"
extra_checks = true
follow_imports = "silent"
warn_redundant_casts = true
warn_unreachable = true
warn_unused_ignores = true
exclude = [
'^src/PIL/_tkinter_finder.py$',
'^src/PIL/DdsImagePlugin.py$',
'^src/PIL/FpxImagePlugin.py$',
'^src/PIL/Image.py$',
'^src/PIL/ImageCms.py$',
'^src/PIL/ImageFile.py$',
'^src/PIL/ImageFont.py$',
'^src/PIL/ImageMath.py$',
'^src/PIL/ImageMorph.py$',
'^src/PIL/ImageQt.py$',
'^src/PIL/ImageShow.py$',
'^src/PIL/ImImagePlugin.py$',
'^src/PIL/MicImagePlugin.py$',
'^src/PIL/PdfParser.py$',
'^src/PIL/PyAccess.py$',
'^src/PIL/TiffImagePlugin.py$',
'^src/PIL/TiffTags.py$',
'^src/PIL/WebPImagePlugin.py$',
]
8 changes: 8 additions & 0 deletions tox.ini
Expand Up @@ -29,3 +29,11 @@ pass_env =
commands =
pre-commit run --all-files --show-diff-on-failure
check-manifest

[testenv:mypy]
skip_install = true
deps =
mypy==1.7.1
hugovk marked this conversation as resolved.
Show resolved Hide resolved
numpy
commands =
mypy src {posargs}
hugovk marked this conversation as resolved.
Show resolved Hide resolved