8000 gh-104050: Run mypy on `clinic.py` in CI by AlexWaygood · Pull Request #104421 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104050: Run mypy on clinic.py in CI #104421

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

Merged
merged 16 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert "Restore compatibility with Python 3.8"
This reverts commit 9fcd87f.
  • Loading branch information
AlexWaygood committed May 15, 2023
commit 010f0dd313f36d34f2a0e52659e20a44e117efc8
14 changes: 3 additions & 11 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Licensed to the PSF under a contributor agreement.
#

from __future__ import annotations

import abc
import ast
import builtins as bltns
Expand All @@ -29,15 +27,9 @@
import traceback
import types

from collections.abc import Callable
from types import *
from typing import Any, Callable, Dict, NamedTuple, TYPE_CHECKING

# types.NoneType only exists on Python 3.10+
# type(None) isn't understood by type-checkers on <3.10 :(
if TYPE_CHECKING:
from _typeshed import NoneType
else:
NoneType = type(None)
from typing import Any, NamedTuple

# TODO:
#
Expand Down Expand Up @@ -1943,7 +1935,7 @@ def dump(self):
# maps strings to Language objects.
# "languages" maps the name of the language ("C", "Python").
# "extensions" maps the file extension ("c", "py").
LangDict = Dict[str, Callable[[str], Language]]
LangDict = dict[str, Callable[[str], Language]]

languages = { 'C': CLanguage, 'Python': PythonLanguage }
extensions: LangDict = { name: CLanguage for name in "c cc cpp cxx h hh hpp hxx".split() }
Expand Down
8 changes: 3 additions & 5 deletions Tools/clinic/cpp.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from __future__ import annotations

import re
import sys
from typing import Callable, List, Tuple
from collections.abc import Callable


TokenAndCondition = Tuple[str, str]
TokenStack = List[TokenAndCondition]
TokenAndCondition = tuple[str, str]
TokenStack = list[TokenAndCondition]

def negate(condition: str) -> str:
"""
Expand Down
4 changes: 2 additions & 2 deletions Tools/clinic/mypy.ini
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually put my mypy config in a pyproject.toml file these days, but a mypy.ini file feels like it makes more "sense" unless we're planning on adding other linters/formatters to check clinic.py in the future

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
# make sure clinic can still be run on Python 3.8
python_version = 3.8
# make sure clinic can still be run on Python 3.10
python_version = 3.10
pretty = True
enable_error_code = ignore-without-code
disallow_any_generics = True
Expand Down
0