mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Fix or ignore type errors generated by the next release of pytype.
The next release contains one major change: for function parameter annotations, pytype will no longer treat (x: X = None) as equivalent to (x: Optional[X] = None). This pytype behavior was based on an outdated version of the type-checking spec. Annotations that were relying on the behavior now need to explicitly declare themselves as Optional. PiperOrigin-RevId: 297065077 Change-Id: Iade679e5928bb3839485e8b8571945456ba6e982
This commit is contained in:
parent
5a4e3f3d29
commit
6332df5ef6
|
@ -233,7 +233,7 @@ class Type(object):
|
||||||
return decl
|
return decl
|
||||||
|
|
||||||
def get_related_types(self, result=None, skip_self=False):
|
def get_related_types(self, result=None, skip_self=False):
|
||||||
# type: (Set[Type], bool) -> Set[Type]
|
# type: (Optional[Set[Type]], bool) -> Set[Type]
|
||||||
"""Returns all types related to this one eg. typedefs, nested structs."""
|
"""Returns all types related to this one eg. typedefs, nested structs."""
|
||||||
if result is None:
|
if result is None:
|
||||||
result = set()
|
result = set()
|
||||||
|
@ -385,7 +385,7 @@ class ArgumentType(Type):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, function, pos, arg_type, name=None):
|
def __init__(self, function, pos, arg_type, name=None):
|
||||||
# type: (Function, int, cindex.Type, Text) -> None
|
# type: (Function, int, cindex.Type, Optional[Text]) -> None
|
||||||
super(ArgumentType, self).__init__(function.translation_unit(), arg_type)
|
super(ArgumentType, self).__init__(function.translation_unit(), arg_type)
|
||||||
self._function = function
|
self._function = function
|
||||||
|
|
||||||
|
@ -527,7 +527,7 @@ class Function(object):
|
||||||
return prefix + self.get_absolute_path().split('/')[-1]
|
return prefix + self.get_absolute_path().split('/')[-1]
|
||||||
|
|
||||||
def get_related_types(self, processed=None):
|
def get_related_types(self, processed=None):
|
||||||
# type: (Set[Type]) -> Set[Type]
|
# type: (Optional[Set[Type]]) -> Set[Type]
|
||||||
result = self.result.get_related_types(processed)
|
result = self.result.get_related_types(processed)
|
||||||
for a in self.argument_types:
|
for a in self.argument_types:
|
||||||
result.update(a.get_related_types(processed))
|
result.update(a.get_related_types(processed))
|
||||||
|
@ -630,7 +630,7 @@ class Analyzer(object):
|
||||||
test_file_existence=True,
|
test_file_existence=True,
|
||||||
unsaved_files=None
|
unsaved_files=None
|
||||||
):
|
):
|
||||||
# type: (Text, List[Text], bool, Tuple[Text, Union[Text, IO[Text]]]) -> _TranslationUnit
|
# type: (Text, Optional[List[Text]], bool, Optional[Tuple[Text, Union[Text, IO[Text]]]]) -> _TranslationUnit
|
||||||
"""Returns Analysis object for given path."""
|
"""Returns Analysis object for given path."""
|
||||||
compile_flags = compile_flags or []
|
compile_flags = compile_flags or []
|
||||||
if test_file_existence and not os.path.isfile(path):
|
if test_file_existence and not os.path.isfile(path):
|
||||||
|
@ -678,9 +678,10 @@ class Generator(object):
|
||||||
self.functions = None
|
self.functions = None
|
||||||
_init_libclang()
|
_init_libclang()
|
||||||
|
|
||||||
|
# pylint: disable=line-too-long
|
||||||
def generate(self, name, function_names, namespace=None, output_file=None,
|
def generate(self, name, function_names, namespace=None, output_file=None,
|
||||||
embed_dir=None, embed_name=None):
|
embed_dir=None, embed_name=None):
|
||||||
# type: (Text, List[Text], Text, Text, Text, Text) -> Text
|
# type: (Text, List[Text], Optional[Text], Optional[Text], Optional[Text], Optional[Text]) -> Text
|
||||||
"""Generates structures, functions and typedefs.
|
"""Generates structures, functions and typedefs.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -714,7 +715,7 @@ class Generator(object):
|
||||||
return self.format_template(**api)
|
return self.format_template(**api)
|
||||||
|
|
||||||
def _get_functions(self, func_names=None):
|
def _get_functions(self, func_names=None):
|
||||||
# type: (List[Text]) -> List[Function]
|
# type: (Optional[List[Text]]) -> List[Function]
|
||||||
"""Gets Function objects that will be used to generate interface."""
|
"""Gets Function objects that will be used to generate interface."""
|
||||||
if self.functions is not None:
|
if self.functions is not None:
|
||||||
return self.functions
|
return self.functions
|
||||||
|
@ -733,7 +734,7 @@ class Generator(object):
|
||||||
return self.functions
|
return self.functions
|
||||||
|
|
||||||
def _get_related_types(self, func_names=None):
|
def _get_related_types(self, func_names=None):
|
||||||
# type: (List[Text]) -> List[Type]
|
# type: (Optional[List[Text]]) -> List[Type]
|
||||||
"""Gets type definitions related to chosen functions.
|
"""Gets type definitions related to chosen functions.
|
||||||
|
|
||||||
Types related to one function will land in the same translation unit,
|
Types related to one function will land in the same translation unit,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user