[clang] [libclang/python] type-ignore `Any` returns from library calls (PR #101310)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 31 02:31:50 PDT 2024
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/101310
On its own, this change leads to _more_ strict typing errors as the functions are mostly not annotated so far, so the `# type: ignore`s are reported as Unused. This is part of the work leading up to #78114 though, and one of the bigger parts factored out from it, so these will later lead to less strict typing errors as the functions are annotated with return types.
>From 7bf4412849774be51c170584089bde8010d0814a Mon Sep 17 00:00:00 2001
From: Jannick Kremer <jannick.kremer at mailbox.org>
Date: Wed, 31 Jul 2024 10:27:09 +0100
Subject: [PATCH] [libclang/python] type-ignore `Any` returns from library
calls
---
clang/bindings/python/clang/cindex.py | 194 +++++++++++++-------------
1 file changed, 97 insertions(+), 97 deletions(-)
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index 72509a8a54f28..60723e1aaeff7 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -276,7 +276,7 @@ def from_position(tu, file, line, column):
Retrieve the source location associated with a given file/line/column in
a particular translation unit.
"""
- return conf.lib.clang_getLocation(tu, file, line, column)
+ return conf.lib.clang_getLocation(tu, file, line, column) # type: ignore [no-any-return]
@staticmethod
def from_offset(tu, file, offset):
@@ -286,7 +286,7 @@ def from_offset(tu, file, offset):
file -- File instance to obtain offset from
offset -- Integer character offset within file
"""
- return conf.lib.clang_getLocationForOffset(tu, file, offset)
+ return conf.lib.clang_getLocationForOffset(tu, file, offset) # type: ignore [no-any-return]
@property
def file(self):
@@ -311,10 +311,10 @@ def offset(self):
@property
def is_in_system_header(self):
"""Returns true if the given source location is in a system header."""
- return conf.lib.clang_Location_isInSystemHeader(self)
+ return conf.lib.clang_Location_isInSystemHeader(self) # type: ignore [no-any-return]
def __eq__(self, other):
- return conf.lib.clang_equalLocations(self, other)
+ return conf.lib.clang_equalLocations(self, other) # type: ignore [no-any-return]
def __ne__(self, other):
return not self.__eq__(other)
@@ -347,7 +347,7 @@ class SourceRange(Structure):
# object.
@staticmethod
def from_locations(start, end):
- return conf.lib.clang_getRange(start, end)
+ return conf.lib.clang_getRange(start, end) # type: ignore [no-any-return]
@property
def start(self):
@@ -355,7 +355,7 @@ def start(self):
Return a SourceLocation representing the first character within a
source range.
"""
- return conf.lib.clang_getRangeStart(self)
+ return conf.lib.clang_getRangeStart(self) # type: ignore [no-any-return]
@property
def end(self):
@@ -363,10 +363,10 @@ def end(self):
Return a SourceLocation representing the last character within a
source range.
"""
- return conf.lib.clang_getRangeEnd(self)
+ return conf.lib.clang_getRangeEnd(self) # type: ignore [no-any-return]
def __eq__(self, other):
- return conf.lib.clang_equalRanges(self, other)
+ return conf.lib.clang_equalRanges(self, other) # type: ignore [no-any-return]
def __ne__(self, other):
return not self.__eq__(other)
@@ -429,15 +429,15 @@ def __del__(self):
@property
def severity(self):
- return conf.lib.clang_getDiagnosticSeverity(self)
+ return conf.lib.clang_getDiagnosticSeverity(self) # type: ignore [no-any-return]
@property
def location(self):
- return conf.lib.clang_getDiagnosticLocation(self)
+ return conf.lib.clang_getDiagnosticLocation(self) # type: ignore [no-any-return]
@property
def spelling(self):
- return conf.lib.clang_getDiagnosticSpelling(self)
+ return conf.lib.clang_getDiagnosticSpelling(self) # type: ignore [no-any-return]
@property
def ranges(self) -> NoSliceSequence[SourceRange]:
@@ -451,7 +451,7 @@ def __len__(self) -> int:
def __getitem__(self, key: int) -> SourceRange:
if key >= len(self):
raise IndexError
- return conf.lib.clang_getDiagnosticRange(self.diag, key)
+ return conf.lib.clang_getDiagnosticRange(self.diag, key) # type: ignore [no-any-return]
return RangeIterator(self)
@@ -494,17 +494,17 @@ def __getitem__(self, key: int) -> Diagnostic:
@property
def category_number(self):
"""The category number for this diagnostic or 0 if unavailable."""
- return conf.lib.clang_getDiagnosticCategory(self)
+ return conf.lib.clang_getDiagnosticCategory(self) # type: ignore [no-any-return]
@property
def category_name(self):
"""The string name of the category for this diagnostic."""
- return conf.lib.clang_getDiagnosticCategoryText(self)
+ return conf.lib.clang_getDiagnosticCategoryText(self) # type: ignore [no-any-return]
@property
def option(self):
"""The command-line option that enables this diagnostic."""
- return conf.lib.clang_getDiagnosticOption(self, None)
+ return conf.lib.clang_getDiagnosticOption(self, None) # type: ignore [no-any-return]
@property
def disable_option(self):
@@ -524,7 +524,7 @@ def format(self, options=None):
options = conf.lib.clang_defaultDiagnosticDisplayOptions()
if options & ~Diagnostic._FormatOptionsMask:
raise ValueError("Invalid format options")
- return conf.lib.clang_formatDiagnostic(self, options)
+ return conf.lib.clang_formatDiagnostic(self, options) # type: ignore [no-any-return]
def __repr__(self):
return "<Diagnostic severity %r, location %r, spelling %r>" % (
@@ -659,39 +659,39 @@ def get_all_kinds():
def is_declaration(self):
"""Test if this is a declaration kind."""
- return conf.lib.clang_isDeclaration(self)
+ return conf.lib.clang_isDeclaration(self) # type: ignore [no-any-return]
def is_reference(self):
"""Test if this is a reference kind."""
- return conf.lib.clang_isReference(self)
+ return conf.lib.clang_isReference(self) # type: ignore [no-any-return]
def is_expression(self):
"""Test if this is an expression kind."""
- return conf.lib.clang_isExpression(self)
+ return conf.lib.clang_isExpression(self) # type: ignore [no-any-return]
def is_statement(self):
"""Test if this is a statement kind."""
- return conf.lib.clang_isStatement(self)
+ return conf.lib.clang_isStatement(self) # type: ignore [no-any-return]
def is_attribute(self):
"""Test if this is an attribute kind."""
- return conf.lib.clang_isAttribute(self)
+ return conf.lib.clang_isAttribute(self) # type: ignore [no-any-return]
def is_invalid(self):
"""Test if this is an invalid kind."""
- return conf.lib.clang_isInvalid(self)
+ return conf.lib.clang_isInvalid(self) # type: ignore [no-any-return]
def is_translation_unit(self):
"""Test if this is a translation unit kind."""
- return conf.lib.clang_isTranslationUnit(self)
+ return conf.lib.clang_isTranslationUnit(self) # type: ignore [no-any-return]
def is_preprocessing(self):
"""Test if this is a preprocessing kind."""
- return conf.lib.clang_isPreprocessing(self)
+ return conf.lib.clang_isPreprocessing(self) # type: ignore [no-any-return]
def is_unexposed(self):
"""Test if this is an unexposed kind."""
- return conf.lib.clang_isUnexposed(self)
+ return conf.lib.clang_isUnexposed(self) # type: ignore [no-any-return]
###
@@ -1564,7 +1564,7 @@ def from_location(tu, location):
return cursor
def __eq__(self, other):
- return conf.lib.clang_equalCursors(self, other)
+ return conf.lib.clang_equalCursors(self, other) # type: ignore [no-any-return]
def __ne__(self, other):
return not self.__eq__(other)
@@ -1574,41 +1574,41 @@ def is_definition(self):
Returns true if the declaration pointed at by the cursor is also a
definition of that entity.
"""
- return conf.lib.clang_isCursorDefinition(self)
+ return conf.lib.clang_isCursorDefinition(self) # type: ignore [no-any-return]
def is_const_method(self):
"""Returns True if the cursor refers to a C++ member function or member
function template that is declared 'const'.
"""
- return conf.lib.clang_CXXMethod_isConst(self)
+ return conf.lib.clang_CXXMethod_isConst(self) # type: ignore [no-any-return]
def is_converting_constructor(self):
"""Returns True if the cursor refers to a C++ converting constructor."""
- return conf.lib.clang_CXXConstructor_isConvertingConstructor(self)
+ return conf.lib.clang_CXXConstructor_isConvertingConstructor(self) # type: ignore [no-any-return]
def is_copy_constructor(self):
"""Returns True if the cursor refers to a C++ copy constructor."""
- return conf.lib.clang_CXXConstructor_isCopyConstructor(self)
+ return conf.lib.clang_CXXConstructor_isCopyConstructor(self) # type: ignore [no-any-return]
def is_default_constructor(self):
"""Returns True if the cursor refers to a C++ default constructor."""
- return conf.lib.clang_CXXConstructor_isDefaultConstructor(self)
+ return conf.lib.clang_CXXConstructor_isDefaultConstructor(self) # type: ignore [no-any-return]
def is_move_constructor(self):
"""Returns True if the cursor refers to a C++ move constructor."""
- return conf.lib.clang_CXXConstructor_isMoveConstructor(self)
+ return conf.lib.clang_CXXConstructor_isMoveConstructor(self) # type: ignore [no-any-return]
def is_default_method(self):
"""Returns True if the cursor refers to a C++ member function or member
function template that is declared '= default'.
"""
- return conf.lib.clang_CXXMethod_isDefaulted(self)
+ return conf.lib.clang_CXXMethod_isDefaulted(self) # type: ignore [no-any-return]
def is_deleted_method(self):
"""Returns True if the cursor refers to a C++ member function or member
function template that is declared '= delete'.
"""
- return conf.lib.clang_CXXMethod_isDeleted(self)
+ return conf.lib.clang_CXXMethod_isDeleted(self) # type: ignore [no-any-return]
def is_copy_assignment_operator_method(self):
"""Returnrs True if the cursor refers to a copy-assignment operator.
@@ -1633,7 +1633,7 @@ class Bar {
Is not.
"""
- return conf.lib.clang_CXXMethod_isCopyAssignmentOperator(self)
+ return conf.lib.clang_CXXMethod_isCopyAssignmentOperator(self) # type: ignore [no-any-return]
def is_move_assignment_operator_method(self):
"""Returnrs True if the cursor refers to a move-assignment operator.
@@ -1658,7 +1658,7 @@ class Bar {
Is not.
"""
- return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self)
+ return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self) # type: ignore [no-any-return]
def is_explicit_method(self):
"""Determines if a C++ constructor or conversion function is
@@ -1703,41 +1703,41 @@ class Foo {
This method will return 0 for the constructor and 1 for
the conversion function.
"""
- return conf.lib.clang_CXXMethod_isExplicit(self)
+ return conf.lib.clang_CXXMethod_isExplicit(self) # type: ignore [no-any-return]
def is_mutable_field(self):
"""Returns True if the cursor refers to a C++ field that is declared
'mutable'.
"""
- return conf.lib.clang_CXXField_isMutable(self)
+ return conf.lib.clang_CXXField_isMutable(self) # type: ignore [no-any-return]
def is_pure_virtual_method(self):
"""Returns True if the cursor refers to a C++ member function or member
function template that is declared pure virtual.
"""
- return conf.lib.clang_CXXMethod_isPureVirtual(self)
+ return conf.lib.clang_CXXMethod_isPureVirtual(self) # type: ignore [no-any-return]
def is_static_method(self):
"""Returns True if the cursor refers to a C++ member function or member
function template that is declared 'static'.
"""
- return conf.lib.clang_CXXMethod_isStatic(self)
+ return conf.lib.clang_CXXMethod_isStatic(self) # type: ignore [no-any-return]
def is_virtual_method(self):
"""Returns True if the cursor refers to a C++ member function or member
function template that is declared 'virtual'.
"""
- return conf.lib.clang_CXXMethod_isVirtual(self)
+ return conf.lib.clang_CXXMethod_isVirtual(self) # type: ignore [no-any-return]
def is_abstract_record(self):
"""Returns True if the cursor refers to a C++ record declaration
that has pure virtual member functions.
"""
- return conf.lib.clang_CXXRecord_isAbstract(self)
+ return conf.lib.clang_CXXRecord_isAbstract(self) # type: ignore [no-any-return]
def is_scoped_enum(self):
"""Returns True if the cursor refers to a scoped enum declaration."""
- return conf.lib.clang_EnumDecl_isScoped(self)
+ return conf.lib.clang_EnumDecl_isScoped(self) # type: ignore [no-any-return]
def get_definition(self):
"""
@@ -1747,7 +1747,7 @@ def get_definition(self):
"""
# TODO: Should probably check that this is either a reference or
# declaration prior to issuing the lookup.
- return conf.lib.clang_getCursorDefinition(self)
+ return conf.lib.clang_getCursorDefinition(self) # type: ignore [no-any-return]
def get_usr(self):
"""Return the Unified Symbol Resolution (USR) for the entity referenced
@@ -1758,13 +1758,13 @@ def get_usr(self):
program. USRs can be compared across translation units to determine,
e.g., when references in one translation refer to an entity defined in
another translation unit."""
- return conf.lib.clang_getCursorUSR(self)
+ return conf.lib.clang_getCursorUSR(self) # type: ignore [no-any-return]
def get_included_file(self):
"""Returns the File that is included by the current inclusion cursor."""
assert self.kind == CursorKind.INCLUSION_DIRECTIVE
- return conf.lib.clang_getIncludedFile(self)
+ return conf.lib.clang_getIncludedFile(self) # type: ignore [no-any-return]
@property
def kind(self):
@@ -2034,12 +2034,12 @@ def referenced(self):
@property
def brief_comment(self):
"""Returns the brief comment text associated with that Cursor"""
- return conf.lib.clang_Cursor_getBriefCommentText(self)
+ return conf.lib.clang_Cursor_getBriefCommentText(self) # type: ignore [no-any-return]
@property
def raw_comment(self):
"""Returns the raw comment text associated with that Cursor"""
- return conf.lib.clang_Cursor_getRawCommentText(self)
+ return conf.lib.clang_Cursor_getRawCommentText(self) # type: ignore [no-any-return]
def get_arguments(self):
"""Return an iterator for accessing the arguments of this cursor."""
@@ -2049,24 +2049,24 @@ def get_arguments(self):
def get_num_template_arguments(self):
"""Returns the number of template args associated with this cursor."""
- return conf.lib.clang_Cursor_getNumTemplateArguments(self)
+ return conf.lib.clang_Cursor_getNumTemplateArguments(self) # type: ignore [no-any-return]
def get_template_argument_kind(self, num):
"""Returns the TemplateArgumentKind for the indicated template
argument."""
- return conf.lib.clang_Cursor_getTemplateArgumentKind(self, num)
+ return conf.lib.clang_Cursor_getTemplateArgumentKind(self, num) # type: ignore [no-any-return]
def get_template_argument_type(self, num):
"""Returns the CXType for the indicated template argument."""
- return conf.lib.clang_Cursor_getTemplateArgumentType(self, num)
+ return conf.lib.clang_Cursor_getTemplateArgumentType(self, num) # type: ignore [no-any-return]
def get_template_argument_value(self, num):
"""Returns the value of the indicated arg as a signed 64b integer."""
- return conf.lib.clang_Cursor_getTemplateArgumentValue(self, num)
+ return conf.lib.clang_Cursor_getTemplateArgumentValue(self, num) # type: ignore [no-any-return]
def get_template_argument_unsigned_value(self, num):
"""Returns the value of the indicated arg as an unsigned 64b integer."""
- return conf.lib.clang_Cursor_getTemplateArgumentUnsignedValue(self, num)
+ return conf.lib.clang_Cursor_getTemplateArgumentUnsignedValue(self, num) # type: ignore [no-any-return]
def get_children(self):
"""Return an iterator for accessing the children of this cursor."""
@@ -2106,7 +2106,7 @@ def get_tokens(self):
def get_field_offsetof(self):
"""Returns the offsetof the FIELD_DECL pointed by this Cursor."""
- return conf.lib.clang_Cursor_getOffsetOfField(self)
+ return conf.lib.clang_Cursor_getOffsetOfField(self) # type: ignore [no-any-return]
def is_anonymous(self):
"""
@@ -2114,19 +2114,19 @@ def is_anonymous(self):
"""
if self.kind == CursorKind.FIELD_DECL:
return self.type.get_declaration().is_anonymous()
- return conf.lib.clang_Cursor_isAnonymous(self)
+ return conf.lib.clang_Cursor_isAnonymous(self) # type: ignore [no-any-return]
def is_bitfield(self):
"""
Check if the field is a bitfield.
"""
- return conf.lib.clang_Cursor_isBitField(self)
+ return conf.lib.clang_Cursor_isBitField(self) # type: ignore [no-any-return]
def get_bitfield_width(self):
"""
Retrieve the width of a bitfield.
"""
- return conf.lib.clang_getFieldDeclBitWidth(self)
+ return conf.lib.clang_getFieldDeclBitWidth(self) # type: ignore [no-any-return]
@staticmethod
def from_result(res, fn, args):
@@ -2263,7 +2263,7 @@ class TypeKind(BaseEnumeration):
@property
def spelling(self):
"""Retrieve the spelling of this TypeKind."""
- return conf.lib.clang_getTypeKindSpelling(self.value)
+ return conf.lib.clang_getTypeKindSpelling(self.value) # type: ignore [no-any-return]
INVALID = 0
UNEXPOSED = 1
@@ -2510,10 +2510,10 @@ def from_result(res, fn, args):
return res
def get_num_template_arguments(self):
- return conf.lib.clang_Type_getNumTemplateArguments(self)
+ return conf.lib.clang_Type_getNumTemplateArguments(self) # type: ignore [no-any-return]
def get_template_argument_type(self, num):
- return conf.lib.clang_Type_getTemplateArgumentAsType(self, num)
+ return conf.lib.clang_Type_getTemplateArgumentAsType(self, num) # type: ignore [no-any-return]
def get_canonical(self):
"""
@@ -2525,7 +2525,7 @@ def get_canonical(self):
example, if 'T' is a typedef for 'int', the canonical type for
'T' would be 'int'.
"""
- return conf.lib.clang_getCanonicalType(self)
+ return conf.lib.clang_getCanonicalType(self) # type: ignore [no-any-return]
def is_const_qualified(self):
"""Determine whether a Type has the "const" qualifier set.
@@ -2533,7 +2533,7 @@ def is_const_qualified(self):
This does not look through typedefs that may have added "const"
at a different level.
"""
- return conf.lib.clang_isConstQualifiedType(self)
+ return conf.lib.clang_isConstQualifiedType(self) # type: ignore [no-any-return]
def is_volatile_qualified(self):
"""Determine whether a Type has the "volatile" qualifier set.
@@ -2541,7 +2541,7 @@ def is_volatile_qualified(self):
This does not look through typedefs that may have added "volatile"
at a different level.
"""
- return conf.lib.clang_isVolatileQualifiedType(self)
+ return conf.lib.clang_isVolatileQualifiedType(self) # type: ignore [no-any-return]
def is_restrict_qualified(self):
"""Determine whether a Type has the "restrict" qualifier set.
@@ -2549,83 +2549,83 @@ def is_restrict_qualified(self):
This does not look through typedefs that may have added "restrict" at
a different level.
"""
- return conf.lib.clang_isRestrictQualifiedType(self)
+ return conf.lib.clang_isRestrictQualifiedType(self) # type: ignore [no-any-return]
def is_function_variadic(self):
"""Determine whether this function Type is a variadic function type."""
assert self.kind == TypeKind.FUNCTIONPROTO
- return conf.lib.clang_isFunctionTypeVariadic(self)
+ return conf.lib.clang_isFunctionTypeVariadic(self) # type: ignore [no-any-return]
def get_address_space(self):
- return conf.lib.clang_getAddressSpace(self)
+ return conf.lib.clang_getAddressSpace(self) # type: ignore [no-any-return]
def get_typedef_name(self):
- return conf.lib.clang_getTypedefName(self)
+ return conf.lib.clang_getTypedefName(self) # type: ignore [no-any-return]
def is_pod(self):
"""Determine whether this Type represents plain old data (POD)."""
- return conf.lib.clang_isPODType(self)
+ return conf.lib.clang_isPODType(self) # type: ignore [no-any-return]
def get_pointee(self):
"""
For pointer types, returns the type of the pointee.
"""
- return conf.lib.clang_getPointeeType(self)
+ return conf.lib.clang_getPointeeType(self) # type: ignore [no-any-return]
def get_declaration(self):
"""
Return the cursor for the declaration of the given type.
"""
- return conf.lib.clang_getTypeDeclaration(self)
+ return conf.lib.clang_getTypeDeclaration(self) # type: ignore [no-any-return]
def get_result(self):
"""
Retrieve the result type associated with a function type.
"""
- return conf.lib.clang_getResultType(self)
+ return conf.lib.clang_getResultType(self) # type: ignore [no-any-return]
def get_array_element_type(self):
"""
Retrieve the type of the elements of the array type.
"""
- return conf.lib.clang_getArrayElementType(self)
+ return conf.lib.clang_getArrayElementType(self) # type: ignore [no-any-return]
def get_array_size(self):
"""
Retrieve the size of the constant array.
"""
- return conf.lib.clang_getArraySize(self)
+ return conf.lib.clang_getArraySize(self) # type: ignore [no-any-return]
def get_class_type(self):
"""
Retrieve the class type of the member pointer type.
"""
- return conf.lib.clang_Type_getClassType(self)
+ return conf.lib.clang_Type_getClassType(self) # type: ignore [no-any-return]
def get_named_type(self):
"""
Retrieve the type named by the qualified-id.
"""
- return conf.lib.clang_Type_getNamedType(self)
+ return conf.lib.clang_Type_getNamedType(self) # type: ignore [no-any-return]
def get_align(self):
"""
Retrieve the alignment of the record.
"""
- return conf.lib.clang_Type_getAlignOf(self)
+ return conf.lib.clang_Type_getAlignOf(self) # type: ignore [no-any-return]
def get_size(self):
"""
Retrieve the size of the record.
"""
- return conf.lib.clang_Type_getSizeOf(self)
+ return conf.lib.clang_Type_getSizeOf(self) # type: ignore [no-any-return]
def get_offset(self, fieldname):
"""
Retrieve the offset of a field in the record.
"""
- return conf.lib.clang_Type_getOffsetOf(self, fieldname)
+ return conf.lib.clang_Type_getOffsetOf(self, fieldname) # type: ignore [no-any-return]
def get_ref_qualifier(self):
"""
@@ -2660,13 +2660,13 @@ def get_exception_specification_kind(self):
@property
def spelling(self):
"""Retrieve the spelling of this Type."""
- return conf.lib.clang_getTypeSpelling(self)
+ return conf.lib.clang_getTypeSpelling(self) # type: ignore [no-any-return]
def __eq__(self, other):
if type(other) != type(self):
return False
- return conf.lib.clang_equalTypes(self, other)
+ return conf.lib.clang_equalTypes(self, other) # type: ignore [no-any-return]
def __ne__(self, other):
return not self.__eq__(other)
@@ -2750,7 +2750,7 @@ def __repr__(self):
def spelling(self):
if self.__kindNumber in SpellingCache:
return SpellingCache[self.__kindNumber]
- return conf.lib.clang_getCompletionChunkText(self.cs, self.key)
+ return conf.lib.clang_getCompletionChunkText(self.cs, self.key) # type: ignore [no-any-return]
# We do not use @CachedProperty here, as the manual implementation is
# apparently still significantly faster. Please profile carefully if you
@@ -2833,7 +2833,7 @@ def __len__(self):
@CachedProperty
def num_chunks(self):
- return conf.lib.clang_getNumCompletionChunks(self.obj)
+ return conf.lib.clang_getNumCompletionChunks(self.obj) # type: ignore [no-any-return]
def __getitem__(self, key):
if self.num_chunks <= key:
@@ -2842,7 +2842,7 @@ def __getitem__(self, key):
@property
def priority(self):
- return conf.lib.clang_getCompletionPriority(self.obj)
+ return conf.lib.clang_getCompletionPriority(self.obj) # type: ignore [no-any-return]
@property
def availability(self):
@@ -2852,7 +2852,7 @@ def availability(self):
@property
def briefComment(self):
if conf.function_exists("clang_getCompletionBriefComment"):
- return conf.lib.clang_getCompletionBriefComment(self.obj)
+ return conf.lib.clang_getCompletionBriefComment(self.obj) # type: ignore [no-any-return]
return _CXString()
def __repr__(self):
@@ -2928,7 +2928,7 @@ def __len__(self) -> int:
return int(conf.lib.clang_codeCompleteGetNumDiagnostics(self.ccr))
def __getitem__(self, key: int) -> Diagnostic:
- return conf.lib.clang_codeCompleteGetDiagnostic(self.ccr, key)
+ return conf.lib.clang_codeCompleteGetDiagnostic(self.ccr, key) # type: ignore [no-any-return]
return DiagnosticsItr(self)
@@ -3133,12 +3133,12 @@ def __del__(self):
@property
def cursor(self):
"""Retrieve the cursor that represents the given translation unit."""
- return conf.lib.clang_getTranslationUnitCursor(self)
+ return conf.lib.clang_getTranslationUnitCursor(self) # type: ignore [no-any-return]
@property
def spelling(self):
"""Get the original translation unit source file name."""
- return conf.lib.clang_getTranslationUnitSpelling(self)
+ return conf.lib.clang_getTranslationUnitSpelling(self) # type: ignore [no-any-return]
def get_includes(self):
"""
@@ -3382,12 +3382,12 @@ def from_name(translation_unit, file_name):
@property
def name(self):
"""Return the complete file and path name of the file."""
- return conf.lib.clang_getFileName(self)
+ return conf.lib.clang_getFileName(self) # type: ignore [no-any-return]
@property
def time(self):
"""Return the last modification time of the file."""
- return conf.lib.clang_getFileTime(self)
+ return conf.lib.clang_getFileTime(self) # type: ignore [no-any-return]
def __str__(self):
return self.name
@@ -3466,12 +3466,12 @@ def __init__(self, cmd, ccmds):
@property
def directory(self):
"""Get the working directory for this CompileCommand"""
- return conf.lib.clang_CompileCommand_getDirectory(self.cmd)
+ return conf.lib.clang_CompileCommand_getDirectory(self.cmd) # type: ignore [no-any-return]
@property
def filename(self):
"""Get the working filename for this CompileCommand"""
- return conf.lib.clang_CompileCommand_getFilename(self.cmd)
+ return conf.lib.clang_CompileCommand_getFilename(self.cmd) # type: ignore [no-any-return]
@property
def arguments(self):
@@ -3550,7 +3550,7 @@ def getCompileCommands(self, filename):
Get an iterable object providing all the CompileCommands available to
build filename. Returns None if filename is not found in the database.
"""
- return conf.lib.clang_CompilationDatabase_getCompileCommands(
+ return conf.lib.clang_CompilationDatabase_getCompileCommands( # type: ignore [no-any-return]
self, os.fspath(filename)
)
@@ -3559,7 +3559,7 @@ def getAllCompileCommands(self):
Get an iterable object providing all the CompileCommands available from
the database.
"""
- return conf.lib.clang_CompilationDatabase_getAllCompileCommands(self)
+ return conf.lib.clang_CompilationDatabase_getAllCompileCommands(self) # type: ignore [no-any-return]
class Token(Structure):
@@ -3580,7 +3580,7 @@ def spelling(self):
This is the textual representation of the token in source.
"""
- return conf.lib.clang_getTokenSpelling(self._tu, self)
+ return conf.lib.clang_getTokenSpelling(self._tu, self) # type: ignore [no-any-return]
@property
def kind(self):
@@ -3590,12 +3590,12 @@ def kind(self):
@property
def location(self):
"""The SourceLocation this Token occurs at."""
- return conf.lib.clang_getTokenLocation(self._tu, self)
+ return conf.lib.clang_getTokenLocation(self._tu, self) # type: ignore [no-any-return]
@property
def extent(self):
"""The SourceRange this Token occupies."""
- return conf.lib.clang_getTokenExtent(self._tu, self)
+ return conf.lib.clang_getTokenExtent(self._tu, self) # type: ignore [no-any-return]
@property
def cursor(self):
@@ -3657,7 +3657,7 @@ def overwrite_changed_files(self):
Returns 1 if any files were not saved successfully,
returns 0 otherwise.
"""
- return conf.lib.clang_CXRewriter_overwriteChangedFiles(self)
+ return conf.lib.clang_CXRewriter_overwriteChangedFiles(self) # type: ignore [no-any-return]
def write_main_file_to_stdout(self):
"""
More information about the cfe-commits
mailing list