55import sysconfig
66import tempfile
77import tokenize
8- from typing import IO , Dict , List , Optional , Set , Tuple
8+ from typing import IO , Any , Dict , List , Optional , Set , Tuple
99
1010from pegen .c_generator import CParserGenerator
1111from pegen .grammar import Grammar
1818MOD_DIR = pathlib .Path (__file__ ).resolve ().parent
1919
2020TokenDefinitions = Tuple [Dict [int , str ], Dict [str , int ], Set [str ]]
21+ Incomplete = Any # TODO: install `types-setuptools` and remove this alias
2122
2223
2324def get_extra_flags (compiler_flags : str , compiler_py_flags_nodist : str ) -> List [str ]:
@@ -28,7 +29,7 @@ def get_extra_flags(compiler_flags: str, compiler_py_flags_nodist: str) -> List[
2829 return f"{ flags } { py_flags_nodist } " .split ()
2930
3031
31- def fixup_build_ext (cmd ) :
32+ def fixup_build_ext (cmd : Incomplete ) -> None :
3233 """Function needed to make build_ext tests pass.
3334
3435 When Python was built with --enable-shared on Unix, -L. is not enough to
@@ -74,7 +75,7 @@ def compile_c_extension(
7475 keep_asserts : bool = True ,
7576 disable_optimization : bool = False ,
7677 library_dir : Optional [str ] = None ,
77- ) -> str :
78+ ) -> pathlib . Path :
7879 """Compile the generated source for a parser generator into an extension module.
7980
8081 The extension module will be generated in the same directory as the provided path
@@ -89,12 +90,12 @@ def compile_c_extension(
8990 static library of the common parser sources (this is useful in case you are
9091 creating multiple extensions).
9192 """
92- import setuptools .logging
93+ import setuptools .logging # type: ignore[import]
9394
9495 from setuptools import Extension , Distribution
95- from setuptools ._distutils .dep_util import newer_group
96- from setuptools ._distutils .ccompiler import new_compiler
97- from setuptools ._distutils .sysconfig import customize_compiler
96+ from setuptools ._distutils .dep_util import newer_group # type: ignore[import]
97+ from setuptools ._distutils .ccompiler import new_compiler # type: ignore[import]
98+ from setuptools ._distutils .sysconfig import customize_compiler # type: ignore[import]
9899
99100 if verbose :
100101 setuptools .logging .set_threshold (setuptools .logging .logging .DEBUG )
0 commit comments