remove useless type annotations
These annotations all had a default initializer of the correct type, or a parent class annotation.
This commit is contained in:
parent
03a2a3a677
commit
a01418db0a
|
@ -26,7 +26,7 @@ if T.TYPE_CHECKING:
|
|||
from .compilers import Compiler
|
||||
|
||||
# execinfo is a compiler lib on BSD
|
||||
UNIXY_COMPILER_INTERNAL_LIBS = ['m', 'c', 'pthread', 'dl', 'rt', 'execinfo'] # type: T.List[str]
|
||||
UNIXY_COMPILER_INTERNAL_LIBS = ['m', 'c', 'pthread', 'dl', 'rt', 'execinfo']
|
||||
|
||||
|
||||
class Dedup(enum.Enum):
|
||||
|
@ -94,7 +94,7 @@ class CompilerArgs(T.MutableSequence[str]):
|
|||
# NOTE: not thorough. A list of potential corner cases can be found in
|
||||
# https://github.com/mesonbuild/meson/pull/4593#pullrequestreview-182016038
|
||||
dedup1_prefixes = () # type: T.Tuple[str, ...]
|
||||
dedup1_suffixes = ('.lib', '.dll', '.so', '.dylib', '.a') # type: T.Tuple[str, ...]
|
||||
dedup1_suffixes = ('.lib', '.dll', '.so', '.dylib', '.a')
|
||||
# Match a .so of the form path/to/libfoo.so.0.1.0
|
||||
# Only UNIX shared libraries require this. Others have a fixed extension.
|
||||
dedup1_regex = re.compile(r'([\/\\]|\A)lib.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$')
|
||||
|
@ -102,7 +102,7 @@ class CompilerArgs(T.MutableSequence[str]):
|
|||
# In generate_link() we add external libs without de-dup, but we must
|
||||
# *always* de-dup these because they're special arguments to the linker
|
||||
# TODO: these should probably move too
|
||||
always_dedup_args = tuple('-l' + lib for lib in UNIXY_COMPILER_INTERNAL_LIBS) # type : T.Tuple[str, ...]
|
||||
always_dedup_args = tuple('-l' + lib for lib in UNIXY_COMPILER_INTERNAL_LIBS)
|
||||
|
||||
def __init__(self, compiler: T.Union['Compiler', 'StaticLinker'],
|
||||
iterable: T.Optional[T.Iterable[str]] = None):
|
||||
|
|
|
@ -46,7 +46,7 @@ class IntrospectionHelper(argparse.Namespace):
|
|||
# mimic an argparse namespace
|
||||
def __init__(self, cross_file: str):
|
||||
super().__init__()
|
||||
self.cross_file = cross_file # type: str
|
||||
self.cross_file = cross_file
|
||||
self.native_file = None # type: str
|
||||
self.cmd_line_options = {} # type: T.Dict[str, str]
|
||||
|
||||
|
|
|
@ -3815,7 +3815,7 @@ def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compi
|
|||
# a common occurrence, which would lead to lots of
|
||||
# distracting noise.
|
||||
continue
|
||||
srcfile = srcdir / tdeps[usename].fname # type: Path
|
||||
srcfile = srcdir / tdeps[usename].fname
|
||||
if not srcfile.is_file():
|
||||
if srcfile.name != src.name: # generated source file
|
||||
pass
|
||||
|
@ -3837,7 +3837,7 @@ def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compi
|
|||
ancestor_child = '_'.join(parents)
|
||||
if ancestor_child not in tdeps:
|
||||
raise MesonException("submodule {} relies on ancestor module {} that was not found.".format(submodmatch.group(2).lower(), ancestor_child.split('_', maxsplit=1)[0]))
|
||||
submodsrcfile = srcdir / tdeps[ancestor_child].fname # type: Path
|
||||
submodsrcfile = srcdir / tdeps[ancestor_child].fname
|
||||
if not submodsrcfile.is_file():
|
||||
if submodsrcfile.name != src.name: # generated source file
|
||||
pass
|
||||
|
|
|
@ -167,10 +167,10 @@ class CMakeInclude:
|
|||
class CMakeFileGroup:
|
||||
def __init__(self, data: T.Dict[str, T.Any]) -> None:
|
||||
self.defines = data.get('defines', '') # type: str
|
||||
self.flags = _flags_to_list(data.get('compileFlags', '')) # type: T.List[str]
|
||||
self.flags = _flags_to_list(data.get('compileFlags', ''))
|
||||
self.is_generated = data.get('isGenerated', False) # type: bool
|
||||
self.language = data.get('language', 'C') # type: str
|
||||
self.sources = [Path(x) for x in data.get('sources', [])] # type: T.List[Path]
|
||||
self.sources = [Path(x) for x in data.get('sources', [])]
|
||||
|
||||
# Fix the include directories
|
||||
self.includes = [] # type: T.List[CMakeInclude]
|
||||
|
@ -196,18 +196,18 @@ class CMakeFileGroup:
|
|||
|
||||
class CMakeTarget:
|
||||
def __init__(self, data: T.Dict[str, T.Any]) -> None:
|
||||
self.artifacts = [Path(x) for x in data.get('artifacts', [])] # type: T.List[Path]
|
||||
self.src_dir = Path(data.get('sourceDirectory', '')) # type: Path
|
||||
self.build_dir = Path(data.get('buildDirectory', '')) # type: Path
|
||||
self.artifacts = [Path(x) for x in data.get('artifacts', [])]
|
||||
self.src_dir = Path(data.get('sourceDirectory', ''))
|
||||
self.build_dir = Path(data.get('buildDirectory', ''))
|
||||
self.name = data.get('name', '') # type: str
|
||||
self.full_name = data.get('fullName', '') # type: str
|
||||
self.install = data.get('hasInstallRule', False) # type: bool
|
||||
self.install_paths = [Path(x) for x in set(data.get('installPaths', []))] # type: T.List[Path]
|
||||
self.install_paths = [Path(x) for x in set(data.get('installPaths', []))]
|
||||
self.link_lang = data.get('linkerLanguage', '') # type: str
|
||||
self.link_libraries = _flags_to_list(data.get('linkLibraries', '')) # type: T.List[str]
|
||||
self.link_flags = _flags_to_list(data.get('linkFlags', '')) # type: T.List[str]
|
||||
self.link_lang_flags = _flags_to_list(data.get('linkLanguageFlags', '')) # type: T.List[str]
|
||||
# self.link_path = Path(data.get('linkPath', '')) # type: Path
|
||||
self.link_libraries = _flags_to_list(data.get('linkLibraries', ''))
|
||||
self.link_flags = _flags_to_list(data.get('linkFlags', ''))
|
||||
self.link_lang_flags = _flags_to_list(data.get('linkLanguageFlags', ''))
|
||||
# self.link_path = Path(data.get('linkPath', ''))
|
||||
self.type = data.get('type', 'EXECUTABLE') # type: str
|
||||
# self.is_generator_provided = data.get('isGeneratorProvided', False) # type: bool
|
||||
self.files = [] # type: T.List[CMakeFileGroup]
|
||||
|
@ -237,8 +237,8 @@ class CMakeTarget:
|
|||
|
||||
class CMakeProject:
|
||||
def __init__(self, data: T.Dict[str, T.Any]) -> None:
|
||||
self.src_dir = Path(data.get('sourceDirectory', '')) # type: Path
|
||||
self.build_dir = Path(data.get('buildDirectory', '')) # type: Path
|
||||
self.src_dir = Path(data.get('sourceDirectory', ''))
|
||||
self.build_dir = Path(data.get('buildDirectory', ''))
|
||||
self.name = data.get('name', '') # type: str
|
||||
self.targets = [] # type: T.List[CMakeTarget]
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ def parse_generator_expressions(
|
|||
if '$<' not in raw:
|
||||
return raw
|
||||
|
||||
out = '' # type: str
|
||||
i = 0 # type: int
|
||||
out = ''
|
||||
i = 0
|
||||
|
||||
def equal(arg: str) -> str:
|
||||
col_pos = arg.find(',')
|
||||
|
@ -147,10 +147,10 @@ def parse_generator_expressions(
|
|||
nonlocal i
|
||||
i += 2
|
||||
|
||||
func = '' # type: str
|
||||
args = '' # type: str
|
||||
res = '' # type: str
|
||||
exp = '' # type: str
|
||||
func = ''
|
||||
args = ''
|
||||
res = ''
|
||||
exp = ''
|
||||
|
||||
# Determine the body of the expression
|
||||
while i < len(raw):
|
||||
|
|
|
@ -107,8 +107,8 @@ class CMakeTraceParser:
|
|||
self.custom_targets = [] # type: T.List[CMakeGeneratorTarget]
|
||||
|
||||
self.env = env
|
||||
self.permissive = permissive # type: bool
|
||||
self.cmake_version = cmake_version # type: str
|
||||
self.permissive = permissive
|
||||
self.cmake_version = cmake_version
|
||||
self.trace_file = 'cmake_trace.txt'
|
||||
self.trace_file_path = build_dir / self.trace_file
|
||||
self.trace_format = 'json-v1' if version_compare(cmake_version, '>=3.17') else 'human'
|
||||
|
@ -785,7 +785,7 @@ class CMakeTraceParser:
|
|||
|
||||
fixed_list = [] # type: T.List[str]
|
||||
curr_str = None # type: T.Optional[str]
|
||||
path_found = False # type: bool
|
||||
path_found = False
|
||||
|
||||
for i in broken_list:
|
||||
if curr_str is None:
|
||||
|
|
|
@ -87,7 +87,7 @@ class ArmCompiler(Compiler):
|
|||
'1': default_warn_args,
|
||||
'2': default_warn_args + [],
|
||||
'3': default_warn_args + [],
|
||||
'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]]
|
||||
'everything': default_warn_args + []}
|
||||
# Assembly
|
||||
self.can_compile_suffixes.add('s')
|
||||
self.can_compile_suffixes.add('sx')
|
||||
|
|
|
@ -71,7 +71,7 @@ class Xc16Compiler(Compiler):
|
|||
'1': default_warn_args,
|
||||
'2': default_warn_args + [],
|
||||
'3': default_warn_args + [],
|
||||
'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]]
|
||||
'everything': default_warn_args + []}
|
||||
|
||||
def get_always_args(self) -> T.List[str]:
|
||||
return []
|
||||
|
|
|
@ -333,7 +333,7 @@ class BoostLibraryFile():
|
|||
def get_compiler_args(self) -> T.List[str]:
|
||||
args = [] # type: T.List[str]
|
||||
if self.mod_name in boost_libraries:
|
||||
libdef = boost_libraries[self.mod_name] # type: BoostLibrary
|
||||
libdef = boost_libraries[self.mod_name]
|
||||
if self.static:
|
||||
args += libdef.static
|
||||
else:
|
||||
|
|
|
@ -195,8 +195,8 @@ class CudaDependency(SystemDependency):
|
|||
except ValueError:
|
||||
continue
|
||||
# use // for floor instead of / which produces a float
|
||||
major = vers_int // 1000 # type: int
|
||||
minor = (vers_int - major * 1000) // 10 # type: int
|
||||
major = vers_int // 1000
|
||||
minor = (vers_int - major * 1000) // 10
|
||||
return f'{major}.{minor}'
|
||||
return None
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ class Properties:
|
|||
self,
|
||||
properties: T.Optional[T.Dict[str, T.Optional[T.Union[str, bool, int, T.List[str]]]]] = None,
|
||||
):
|
||||
self.properties = properties or {} # type: T.Dict[str, T.Optional[T.Union[str, bool, int, T.List[str]]]]
|
||||
self.properties = properties or {}
|
||||
|
||||
def has_stdlib(self, language: str) -> bool:
|
||||
return language + '_stdlib' in self.properties
|
||||
|
|
|
@ -606,9 +606,9 @@ class FeatureCheckBase(metaclass=abc.ABCMeta):
|
|||
unconditional = False
|
||||
|
||||
def __init__(self, feature_name: str, feature_version: str, extra_message: str = ''):
|
||||
self.feature_name = feature_name # type: str
|
||||
self.feature_version = feature_version # type: str
|
||||
self.extra_message = extra_message # type: str
|
||||
self.feature_name = feature_name
|
||||
self.feature_version = feature_version
|
||||
self.extra_message = extra_message
|
||||
|
||||
@staticmethod
|
||||
def get_target_version(subproject: str) -> str:
|
||||
|
|
|
@ -174,7 +174,7 @@ def generate_target_name_vs(target: ParsedTargetName, builddir: Path, introspect
|
|||
|
||||
# Normalize project name
|
||||
# Source: https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-build-specific-targets-in-solutions-by-using-msbuild-exe
|
||||
target_name = re.sub(r"[\%\$\@\;\.\(\)']", '_', intro_target['id']) # type: str
|
||||
target_name = re.sub(r"[\%\$\@\;\.\(\)']", '_', intro_target['id'])
|
||||
rel_path = Path(intro_target['filename'][0]).relative_to(builddir.resolve()).parent
|
||||
if rel_path != Path('.'):
|
||||
target_name = str(rel_path / target_name)
|
||||
|
|
|
@ -811,7 +811,7 @@ class Parser:
|
|||
return EmptyNode(self.current.lineno, self.current.colno, self.current.filename)
|
||||
|
||||
def key_values(self) -> ArgumentNode:
|
||||
s = self.statement() # type: BaseNode
|
||||
s = self.statement()
|
||||
a = ArgumentNode(self.current)
|
||||
|
||||
while not isinstance(s, EmptyNode):
|
||||
|
@ -828,7 +828,7 @@ class Parser:
|
|||
return a
|
||||
|
||||
def args(self) -> ArgumentNode:
|
||||
s = self.statement() # type: BaseNode
|
||||
s = self.statement()
|
||||
a = ArgumentNode(self.current)
|
||||
|
||||
while not isinstance(s, EmptyNode):
|
||||
|
@ -875,7 +875,7 @@ class Parser:
|
|||
self.expect('id')
|
||||
assert isinstance(t.value, str)
|
||||
varname = t
|
||||
varnames = [t.value] # type: T.List[str]
|
||||
varnames = [t.value]
|
||||
|
||||
if self.accept('comma'):
|
||||
t = self.current
|
||||
|
|
|
@ -524,7 +524,7 @@ class ConsoleLogger(TestLogger):
|
|||
self.running_tests = OrderedSet() # type: OrderedSet['TestRun']
|
||||
self.progress_test = None # type: T.Optional['TestRun']
|
||||
self.progress_task = None # type: T.Optional[asyncio.Future]
|
||||
self.max_left_width = 0 # type: int
|
||||
self.max_left_width = 0
|
||||
self.stop = False
|
||||
# TODO: before 3.10 this cannot be created immediately, because
|
||||
# it will create a new event loop
|
||||
|
@ -933,7 +933,7 @@ class TestRun:
|
|||
self.stde = ''
|
||||
self.additional_error = ''
|
||||
self.cmd = None # type: T.Optional[T.List[str]]
|
||||
self.env = test_env # type: T.Dict[str, str]
|
||||
self.env = test_env
|
||||
self.should_fail = test.should_fail
|
||||
self.project = test.project_name
|
||||
self.junit = None # type: T.Optional[et.ElementTree]
|
||||
|
@ -1285,7 +1285,7 @@ class TestSubprocess:
|
|||
self.stderr = stderr
|
||||
self.stdo_task: T.Optional[asyncio.Task[None]] = None
|
||||
self.stde_task: T.Optional[asyncio.Task[None]] = None
|
||||
self.postwait_fn = postwait_fn # type: T.Callable[[], None]
|
||||
self.postwait_fn = postwait_fn
|
||||
self.all_futures = [] # type: T.List[asyncio.Future]
|
||||
self.queue = None # type: T.Optional[asyncio.Queue[T.Optional[str]]]
|
||||
|
||||
|
|
Loading…
Reference in New Issue