github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash darker --check --diff -r dcb4399f07180bcad4632f152225309ea70f0700...717c43a4c027681fa957ed35a365400c129ff0b1 clang/bindings/python/clang/cindex.py `````````` </details> <details> <summary> View the diff from darker here. </summary> ``````````diff --- cindex.py 2024-07-30 16:34:33.000000 +0000 +++ cindex.py 2024-07-30 16:39:28.320388 +0000 @@ -284,21 +284,21 @@ ) -> SourceLocation: """ 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) # type: ignore [no-any-return] + return conf.lib.clang_getLocation(tu, file, line, column) # type: ignore [no-any-return] @staticmethod def from_offset(tu: TranslationUnit, file: File, offset: int) -> SourceLocation: """Retrieve a SourceLocation from a given character offset. tu -- TranslationUnit file belongs to file -- File instance to obtain offset from offset -- Integer character offset within file """ - return conf.lib.clang_getLocationForOffset(tu, file, offset) # type: ignore [no-any-return] + return conf.lib.clang_getLocationForOffset(tu, file, offset) # type: ignore [no-any-return] @property def file(self) -> File | None: """Get the file represented by this source location.""" return self._get_instantiation()[0] @@ -319,16 +319,16 @@ return self._get_instantiation()[3] @property def is_in_system_header(self) -> bool: """Returns true if the given source location is in a system header.""" - return conf.lib.clang_Location_isInSystemHeader(self) # type: ignore [no-any-return] + return conf.lib.clang_Location_isInSystemHeader(self) # type: ignore [no-any-return] def __eq__(self, other: object) -> bool: if not isinstance(other, SourceLocation): return False - return conf.lib.clang_equalLocations(self, other) # type: ignore [no-any-return] + return conf.lib.clang_equalLocations(self, other) # type: ignore [no-any-return] def __ne__(self, other: object) -> bool: return not self.__eq__(other) def __repr__(self) -> str: @@ -357,32 +357,32 @@ # FIXME: Eliminate this and make normal constructor? Requires hiding ctypes # object. @staticmethod def from_locations(start: SourceLocation, end: SourceLocation) -> SourceRange: - return conf.lib.clang_getRange(start, end) # type: ignore [no-any-return] + return conf.lib.clang_getRange(start, end) # type: ignore [no-any-return] @property def start(self) -> SourceLocation: """ Return a SourceLocation representing the first character within a source range. """ - return conf.lib.clang_getRangeStart(self) # type: ignore [no-any-return] + return conf.lib.clang_getRangeStart(self) # type: ignore [no-any-return] @property def end(self) -> SourceLocation: """ Return a SourceLocation representing the last character within a source range. """ - return conf.lib.clang_getRangeEnd(self) # type: ignore [no-any-return] + return conf.lib.clang_getRangeEnd(self) # type: ignore [no-any-return] def __eq__(self, other: object) -> bool: if not isinstance(other, SourceRange): return False - return conf.lib.clang_equalRanges(self, other) # type: ignore [no-any-return] + return conf.lib.clang_equalRanges(self, other) # type: ignore [no-any-return] def __ne__(self, other: object) -> bool: return not self.__eq__(other) def __contains__(self, other: object) -> bool: @@ -441,19 +441,19 @@ def __del__(self) -> None: conf.lib.clang_disposeDiagnostic(self) @property def severity(self) -> int: - return conf.lib.clang_getDiagnosticSeverity(self) # type: ignore [no-any-return] + return conf.lib.clang_getDiagnosticSeverity(self) # type: ignore [no-any-return] @property def location(self) -> SourceLocation: - return conf.lib.clang_getDiagnosticLocation(self) # type: ignore [no-any-return] + return conf.lib.clang_getDiagnosticLocation(self) # type: ignore [no-any-return] @property def spelling(self) -> str: - return conf.lib.clang_getDiagnosticSpelling(self) # type: ignore [no-any-return] + return conf.lib.clang_getDiagnosticSpelling(self) # type: ignore [no-any-return] @property def ranges(self) -> NoSliceSequence[SourceRange]: class RangeIterator: def __init__(self, diag: Diagnostic): @@ -463,11 +463,11 @@ return int(conf.lib.clang_getDiagnosticNumRanges(self.diag)) def __getitem__(self, key: int) -> SourceRange: if key >= len(self): raise IndexError - return conf.lib.clang_getDiagnosticRange(self.diag, key) # type: ignore [no-any-return] + return conf.lib.clang_getDiagnosticRange(self.diag, key) # type: ignore [no-any-return] return RangeIterator(self) @property def fixits(self) -> NoSliceSequence[FixIt]: @@ -506,21 +506,21 @@ return ChildDiagnosticsIterator(self) @property def category_number(self) -> int: """The category number for this diagnostic or 0 if unavailable.""" - return conf.lib.clang_getDiagnosticCategory(self) # type: ignore [no-any-return] + return conf.lib.clang_getDiagnosticCategory(self) # type: ignore [no-any-return] @property def category_name(self) -> str: """The string name of the category for this diagnostic.""" - return conf.lib.clang_getDiagnosticCategoryText(self) # type: ignore [no-any-return] + return conf.lib.clang_getDiagnosticCategoryText(self) # type: ignore [no-any-return] @property def option(self) -> str: """The command-line option that enables this diagnostic.""" - return conf.lib.clang_getDiagnosticOption(self, None) # type: ignore [no-any-return] + return conf.lib.clang_getDiagnosticOption(self, None) # type: ignore [no-any-return] @property def disable_option(self) -> str: """The command-line option that disables this diagnostic.""" disable = _CXString() @@ -536,11 +536,11 @@ """ if options is None: options = conf.lib.clang_defaultDiagnosticDisplayOptions() if options & ~Diagnostic._FormatOptionsMask: raise ValueError("Invalid format options") - return conf.lib.clang_formatDiagnostic(self, options) # type: ignore [no-any-return] + return conf.lib.clang_formatDiagnostic(self, options) # type: ignore [no-any-return] def __repr__(self) -> str: return "<Diagnostic severity %r, location %r, spelling %r>" % ( self.severity, self.location, @@ -622,10 +622,11 @@ token._tu = tu token._group = token_group yield token + TEnum = TypeVar("TEnum", bound="BaseEnumeration") ### Cursor Kinds ### class BaseEnumeration(Enum): """ @@ -673,44 +674,43 @@ """Return all CursorKind enumeration instances.""" return list(CursorKind) def is_declaration(self) -> bool: """Test if this is a declaration kind.""" - return conf.lib.clang_isDeclaration(self) # type: ignore [no-any-return] + return conf.lib.clang_isDeclaration(self) # type: ignore [no-any-return] def is_reference(self) -> bool: """Test if this is a reference kind.""" - return conf.lib.clang_isReference(self) # type: ignore [no-any-return] + return conf.lib.clang_isReference(self) # type: ignore [no-any-return] def is_expression(self) -> bool: """Test if this is an expression kind.""" - return conf.lib.clang_isExpression(self) # type: ignore [no-any-return] + return conf.lib.clang_isExpression(self) # type: ignore [no-any-return] def is_statement(self) -> bool: """Test if this is a statement kind.""" - return conf.lib.clang_isStatement(self) # type: ignore [no-any-return] + return conf.lib.clang_isStatement(self) # type: ignore [no-any-return] def is_attribute(self) -> bool: """Test if this is an attribute kind.""" - return conf.lib.clang_isAttribute(self) # type: ignore [no-any-return] + return conf.lib.clang_isAttribute(self) # type: ignore [no-any-return] def is_invalid(self) -> bool: """Test if this is an invalid kind.""" - return conf.lib.clang_isInvalid(self) # type: ignore [no-any-return] + return conf.lib.clang_isInvalid(self) # type: ignore [no-any-return] def is_translation_unit(self) -> bool: """Test if this is a translation unit kind.""" - return conf.lib.clang_isTranslationUnit(self) # type: ignore [no-any-return] + return conf.lib.clang_isTranslationUnit(self) # type: ignore [no-any-return] def is_preprocessing(self) -> bool: """Test if this is a preprocessing kind.""" - return conf.lib.clang_isPreprocessing(self) # type: ignore [no-any-return] + return conf.lib.clang_isPreprocessing(self) # type: ignore [no-any-return] def is_unexposed(self) -> bool: """Test if this is an unexposed kind.""" - return conf.lib.clang_isUnexposed(self) # type: ignore [no-any-return] - + return conf.lib.clang_isUnexposed(self) # type: ignore [no-any-return] ### # Declaration Kinds # A declaration whose specific kind is not exposed via this interface. @@ -1582,55 +1582,55 @@ return cursor def __eq__(self, other: object) -> bool: if not isinstance(other, Cursor): return False - return conf.lib.clang_equalCursors(self, other) # type: ignore [no-any-return] + return conf.lib.clang_equalCursors(self, other) # type: ignore [no-any-return] def __ne__(self, other: object) -> bool: return not self.__eq__(other) def is_definition(self) -> bool: """ Returns true if the declaration pointed at by the cursor is also a definition of that entity. """ - return conf.lib.clang_isCursorDefinition(self) # type: ignore [no-any-return] + return conf.lib.clang_isCursorDefinition(self) # type: ignore [no-any-return] def is_const_method(self) -> bool: """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) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isConst(self) # type: ignore [no-any-return] def is_converting_constructor(self) -> bool: """Returns True if the cursor refers to a C++ converting constructor.""" - return conf.lib.clang_CXXConstructor_isConvertingConstructor(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXConstructor_isConvertingConstructor(self) # type: ignore [no-any-return] def is_copy_constructor(self) -> bool: """Returns True if the cursor refers to a C++ copy constructor.""" - return conf.lib.clang_CXXConstructor_isCopyConstructor(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXConstructor_isCopyConstructor(self) # type: ignore [no-any-return] def is_default_constructor(self) -> bool: """Returns True if the cursor refers to a C++ default constructor.""" - return conf.lib.clang_CXXConstructor_isDefaultConstructor(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXConstructor_isDefaultConstructor(self) # type: ignore [no-any-return] def is_move_constructor(self) -> bool: """Returns True if the cursor refers to a C++ move constructor.""" - return conf.lib.clang_CXXConstructor_isMoveConstructor(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXConstructor_isMoveConstructor(self) # type: ignore [no-any-return] def is_default_method(self) -> bool: """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) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isDefaulted(self) # type: ignore [no-any-return] def is_deleted_method(self) -> bool: """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) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isDeleted(self) # type: ignore [no-any-return] def is_copy_assignment_operator_method(self) -> bool: """Returnrs True if the cursor refers to a copy-assignment operator. A copy-assignment operator `X::operator=` is a non-static, @@ -1651,11 +1651,11 @@ bool operator=(const int&); }; Is not. """ - return conf.lib.clang_CXXMethod_isCopyAssignmentOperator(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isCopyAssignmentOperator(self) # type: ignore [no-any-return] def is_move_assignment_operator_method(self) -> bool: """Returnrs True if the cursor refers to a move-assignment operator. A move-assignment operator `X::operator=` is a non-static, @@ -1676,11 +1676,11 @@ bool operator=(const int&&); }; Is not. """ - return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isMoveAssignmentOperator(self) # type: ignore [no-any-return] def is_explicit_method(self) -> bool: """Determines if a C++ constructor or conversion function is explicit, returning 1 if such is the case and 0 otherwise. @@ -1721,72 +1721,72 @@ } This method will return 0 for the constructor and 1 for the conversion function. """ - return conf.lib.clang_CXXMethod_isExplicit(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isExplicit(self) # type: ignore [no-any-return] def is_mutable_field(self) -> bool: """Returns True if the cursor refers to a C++ field that is declared 'mutable'. """ - return conf.lib.clang_CXXField_isMutable(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXField_isMutable(self) # type: ignore [no-any-return] def is_pure_virtual_method(self) -> bool: """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) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isPureVirtual(self) # type: ignore [no-any-return] def is_static_method(self) -> bool: """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) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isStatic(self) # type: ignore [no-any-return] def is_virtual_method(self) -> bool: """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) # type: ignore [no-any-return] + return conf.lib.clang_CXXMethod_isVirtual(self) # type: ignore [no-any-return] def is_abstract_record(self) -> bool: """Returns True if the cursor refers to a C++ record declaration that has pure virtual member functions. """ - return conf.lib.clang_CXXRecord_isAbstract(self) # type: ignore [no-any-return] + return conf.lib.clang_CXXRecord_isAbstract(self) # type: ignore [no-any-return] def is_scoped_enum(self) -> bool: """Returns True if the cursor refers to a scoped enum declaration.""" - return conf.lib.clang_EnumDecl_isScoped(self) # type: ignore [no-any-return] + return conf.lib.clang_EnumDecl_isScoped(self) # type: ignore [no-any-return] def get_definition(self) -> Cursor: """ If the cursor is a reference to a declaration or a declaration of some entity, return a cursor that points to the definition of that entity. """ # TODO: Should probably check that this is either a reference or # declaration prior to issuing the lookup. - return conf.lib.clang_getCursorDefinition(self) # type: ignore [no-any-return] + return conf.lib.clang_getCursorDefinition(self) # type: ignore [no-any-return] def get_usr(self) -> str: """Return the Unified Symbol Resolution (USR) for the entity referenced by the given cursor. A Unified Symbol Resolution (USR) is a string that identifies a particular entity (function, class, variable, etc.) within a 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) # type: ignore [no-any-return] + return conf.lib.clang_getCursorUSR(self) # type: ignore [no-any-return] def get_included_file(self) -> File: """Returns the File that is included by the current inclusion cursor.""" assert self.kind == CursorKind.INCLUSION_DIRECTIVE - return conf.lib.clang_getIncludedFile(self) # type: ignore [no-any-return] + return conf.lib.clang_getIncludedFile(self) # type: ignore [no-any-return] @property def kind(self) -> CursorKind: """Return the kind of this cursor.""" return CursorKind.from_id(self._kind_id) @@ -1956,11 +1956,13 @@ Returns a Type for the typedef this cursor is a declaration for. If the current cursor is not a typedef, this raises. """ if not hasattr(self, "_underlying_type"): assert self.kind.is_declaration() - self._underlying_type: Type = conf.lib.clang_getTypedefDeclUnderlyingType(self) + self._underlying_type: Type = conf.lib.clang_getTypedefDeclUnderlyingType( + self + ) return self._underlying_type @property def enum_type(self) -> Type: @@ -1994,11 +1996,13 @@ TypeKind.UINT, TypeKind.ULONG, TypeKind.ULONGLONG, TypeKind.UINT128, ): - self._enum_value: int = conf.lib.clang_getEnumConstantDeclUnsignedValue(self) + self._enum_value: int = conf.lib.clang_getEnumConstantDeclUnsignedValue( + self + ) else: self._enum_value = conf.lib.clang_getEnumConstantDeclValue(self) return self._enum_value @property @@ -2052,43 +2056,43 @@ return self._referenced @property def brief_comment(self) -> str: """Returns the brief comment text associated with that Cursor""" - return conf.lib.clang_Cursor_getBriefCommentText(self) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_getBriefCommentText(self) # type: ignore [no-any-return] @property def raw_comment(self) -> str: """Returns the raw comment text associated with that Cursor""" - return conf.lib.clang_Cursor_getRawCommentText(self) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_getRawCommentText(self) # type: ignore [no-any-return] def get_arguments(self) -> Iterator[Cursor]: """Return an iterator for accessing the arguments of this cursor.""" num_args = conf.lib.clang_Cursor_getNumArguments(self) for i in range(0, num_args): yield conf.lib.clang_Cursor_getArgument(self, i) def get_num_template_arguments(self) -> int: """Returns the number of template args associated with this cursor.""" - return conf.lib.clang_Cursor_getNumTemplateArguments(self) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_getNumTemplateArguments(self) # type: ignore [no-any-return] def get_template_argument_kind(self, num: int) -> TemplateArgumentKind: """Returns the TemplateArgumentKind for the indicated template argument.""" - return conf.lib.clang_Cursor_getTemplateArgumentKind(self, num) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_getTemplateArgumentKind(self, num) # type: ignore [no-any-return] def get_template_argument_type(self, num: int) -> Type: """Returns the CXType for the indicated template argument.""" - return conf.lib.clang_Cursor_getTemplateArgumentType(self, num) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_getTemplateArgumentType(self, num) # type: ignore [no-any-return] def get_template_argument_value(self, num: int) -> int: """Returns the value of the indicated arg as a signed 64b integer.""" - return conf.lib.clang_Cursor_getTemplateArgumentValue(self, num) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_getTemplateArgumentValue(self, num) # type: ignore [no-any-return] def get_template_argument_unsigned_value(self, num: int) -> int: """Returns the value of the indicated arg as an unsigned 64b integer.""" - return conf.lib.clang_Cursor_getTemplateArgumentUnsignedValue(self, num) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_getTemplateArgumentUnsignedValue(self, num) # type: ignore [no-any-return] def get_children(self) -> Iterator[Cursor]: """Return an iterator for accessing the children of this cursor.""" # FIXME: Expose iteration from CIndex, PR6125. @@ -2124,31 +2128,31 @@ """ return TokenGroup.get_tokens(self._tu, self.extent) def get_field_offsetof(self) -> int: """Returns the offsetof the FIELD_DECL pointed by this Cursor.""" - return conf.lib.clang_Cursor_getOffsetOfField(self) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_getOffsetOfField(self) # type: ignore [no-any-return] def is_anonymous(self) -> bool: """ Check if the record is anonymous. """ if self.kind == CursorKind.FIELD_DECL: return self.type.get_declaration().is_anonymous() - return conf.lib.clang_Cursor_isAnonymous(self) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_isAnonymous(self) # type: ignore [no-any-return] def is_bitfield(self) -> bool: """ Check if the field is a bitfield. """ - return conf.lib.clang_Cursor_isBitField(self) # type: ignore [no-any-return] + return conf.lib.clang_Cursor_isBitField(self) # type: ignore [no-any-return] def get_bitfield_width(self) -> int: """ Retrieve the width of a bitfield. """ - return conf.lib.clang_getFieldDeclBitWidth(self) # type: ignore [no-any-return] + return conf.lib.clang_getFieldDeclBitWidth(self) # type: ignore [no-any-return] @staticmethod def from_result( res: Cursor, fn: Any, args: Sequence[Cursor | TranslationUnit | Type] ) -> Cursor | None: @@ -2285,11 +2289,11 @@ """ @property def spelling(self) -> str: """Retrieve the spelling of this TypeKind.""" - return conf.lib.clang_getTypeKindSpelling(self.value) # type: ignore [no-any-return] + return conf.lib.clang_getTypeKindSpelling(self.value) # type: ignore [no-any-return] INVALID = 0 UNEXPOSED = 1 VOID = 2 BOOL = 3 @@ -2534,14 +2538,14 @@ res._tu = tu return res def get_num_template_arguments(self) -> int: - return conf.lib.clang_Type_getNumTemplateArguments(self) # type: ignore [no-any-return] + return conf.lib.clang_Type_getNumTemplateArguments(self) # type: ignore [no-any-return] def get_template_argument_type(self, num: int) -> Type: - return conf.lib.clang_Type_getTemplateArgumentAsType(self, num) # type: ignore [no-any-return] + return conf.lib.clang_Type_getTemplateArgumentAsType(self, num) # type: ignore [no-any-return] def get_canonical(self) -> Type: """ Return the canonical type for a Type. @@ -2549,111 +2553,111 @@ ways a specific type can be represented. The canonical type is the underlying type with all the "sugar" removed. For example, if 'T' is a typedef for 'int', the canonical type for 'T' would be 'int'. """ - return conf.lib.clang_getCanonicalType(self) # type: ignore [no-any-return] + return conf.lib.clang_getCanonicalType(self) # type: ignore [no-any-return] def is_const_qualified(self) -> bool: """Determine whether a Type has the "const" qualifier set. This does not look through typedefs that may have added "const" at a different level. """ - return conf.lib.clang_isConstQualifiedType(self) # type: ignore [no-any-return] + return conf.lib.clang_isConstQualifiedType(self) # type: ignore [no-any-return] def is_volatile_qualified(self) -> bool: """Determine whether a Type has the "volatile" qualifier set. This does not look through typedefs that may have added "volatile" at a different level. """ - return conf.lib.clang_isVolatileQualifiedType(self) # type: ignore [no-any-return] + return conf.lib.clang_isVolatileQualifiedType(self) # type: ignore [no-any-return] def is_restrict_qualified(self) -> bool: """Determine whether a Type has the "restrict" qualifier set. This does not look through typedefs that may have added "restrict" at a different level. """ - return conf.lib.clang_isRestrictQualifiedType(self) # type: ignore [no-any-return] + return conf.lib.clang_isRestrictQualifiedType(self) # type: ignore [no-any-return] def is_function_variadic(self) -> bool: """Determine whether this function Type is a variadic function type.""" assert self.kind == TypeKind.FUNCTIONPROTO - return conf.lib.clang_isFunctionTypeVariadic(self) # type: ignore [no-any-return] + return conf.lib.clang_isFunctionTypeVariadic(self) # type: ignore [no-any-return] def get_address_space(self) -> int: - return conf.lib.clang_getAddressSpace(self) # type: ignore [no-any-return] + return conf.lib.clang_getAddressSpace(self) # type: ignore [no-any-return] def get_typedef_name(self) -> str: - return conf.lib.clang_getTypedefName(self) # type: ignore [no-any-return] + return conf.lib.clang_getTypedefName(self) # type: ignore [no-any-return] def is_pod(self) -> bool: """Determine whether this Type represents plain old data (POD).""" - return conf.lib.clang_isPODType(self) # type: ignore [no-any-return] + return conf.lib.clang_isPODType(self) # type: ignore [no-any-return] def get_pointee(self) -> Type: """ For pointer types, returns the type of the pointee. """ - return conf.lib.clang_getPointeeType(self) # type: ignore [no-any-return] + return conf.lib.clang_getPointeeType(self) # type: ignore [no-any-return] def get_declaration(self) -> Cursor: """ Return the cursor for the declaration of the given type. """ - return conf.lib.clang_getTypeDeclaration(self) # type: ignore [no-any-return] + return conf.lib.clang_getTypeDeclaration(self) # type: ignore [no-any-return] def get_result(self) -> Type: """ Retrieve the result type associated with a function type. """ - return conf.lib.clang_getResultType(self) # type: ignore [no-any-return] + return conf.lib.clang_getResultType(self) # type: ignore [no-any-return] def get_array_element_type(self) -> Type: """ Retrieve the type of the elements of the array type. """ - return conf.lib.clang_getArrayElementType(self) # type: ignore [no-any-return] + return conf.lib.clang_getArrayElementType(self) # type: ignore [no-any-return] def get_array_size(self) -> int: """ Retrieve the size of the constant array. """ - return conf.lib.clang_getArraySize(self) # type: ignore [no-any-return] + return conf.lib.clang_getArraySize(self) # type: ignore [no-any-return] def get_class_type(self) -> Type: """ Retrieve the class type of the member pointer type. """ - return conf.lib.clang_Type_getClassType(self) # type: ignore [no-any-return] + return conf.lib.clang_Type_getClassType(self) # type: ignore [no-any-return] def get_named_type(self) -> Type: """ Retrieve the type named by the qualified-id. """ - return conf.lib.clang_Type_getNamedType(self) # type: ignore [no-any-return] + return conf.lib.clang_Type_getNamedType(self) # type: ignore [no-any-return] def get_align(self) -> int: """ Retrieve the alignment of the record. """ - return conf.lib.clang_Type_getAlignOf(self) # type: ignore [no-any-return] + return conf.lib.clang_Type_getAlignOf(self) # type: ignore [no-any-return] def get_size(self) -> int: """ Retrieve the size of the record. """ - return conf.lib.clang_Type_getSizeOf(self) # type: ignore [no-any-return] + return conf.lib.clang_Type_getSizeOf(self) # type: ignore [no-any-return] def get_offset(self, fieldname: str) -> int: """ Retrieve the offset of a field in the record. """ - return conf.lib.clang_Type_getOffsetOf(self, fieldname) # type: ignore [no-any-return] + return conf.lib.clang_Type_getOffsetOf(self, fieldname) # type: ignore [no-any-return] def get_ref_qualifier(self) -> RefQualifierKind: """ Retrieve the ref-qualifier of the type. """ @@ -2684,17 +2688,17 @@ ) @property def spelling(self) -> str: """Retrieve the spelling of this Type.""" - return conf.lib.clang_getTypeSpelling(self) # type: ignore [no-any-return] + return conf.lib.clang_getTypeSpelling(self) # type: ignore [no-any-return] def __eq__(self, other: object) -> bool: if not isinstance(other, Type): return False - return conf.lib.clang_equalTypes(self, other) # type: ignore [no-any-return] + return conf.lib.clang_equalTypes(self, other) # type: ignore [no-any-return] def __ne__(self, other: object) -> bool: return not self.__eq__(other) @@ -2774,11 +2778,11 @@ @CachedProperty def spelling(self) -> str: if self.__kindNumber in SpellingCache: return SpellingCache[self.__kindNumber] - return conf.lib.clang_getCompletionChunkText(self.cs, self.key) # type: ignore [no-any-return] + 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 # would like to add CachedProperty back. @property @@ -2857,11 +2861,11 @@ def __len__(self) -> int: return self.num_chunks @CachedProperty def num_chunks(self) -> int: - return conf.lib.clang_getNumCompletionChunks(self.obj) # type: ignore [no-any-return] + return conf.lib.clang_getNumCompletionChunks(self.obj) # type: ignore [no-any-return] def __getitem__(self, key: int) -> CompletionChunk: if self.num_chunks <= key: raise IndexError return CompletionChunk(self.obj, key) @@ -2870,21 +2874,21 @@ for i in range(len(self)): yield self[i] @property def priority(self) -> int: - return conf.lib.clang_getCompletionPriority(self.obj) # type: ignore [no-any-return] + return conf.lib.clang_getCompletionPriority(self.obj) # type: ignore [no-any-return] @property def availability(self) -> CompletionChunk.Kind: res = conf.lib.clang_getCompletionAvailability(self.obj) return availabilityKinds[res] @property def briefComment(self) -> str: if conf.function_exists("clang_getCompletionBriefComment"): - return conf.lib.clang_getCompletionBriefComment(self.obj) # type: ignore [no-any-return] + return conf.lib.clang_getCompletionBriefComment(self.obj) # type: ignore [no-any-return] return "" def __repr__(self) -> str: return ( " | ".join([str(a) for a in self]) @@ -2959,11 +2963,11 @@ 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) # type: ignore [no-any-return] + return conf.lib.clang_codeCompleteGetDiagnostic(self.ccr, key) # type: ignore [no-any-return] return DiagnosticsItr(self) class Index(ClangObject): @@ -3177,16 +3181,16 @@ conf.lib.clang_disposeTranslationUnit(self) @property def cursor(self) -> Cursor: """Retrieve the cursor that represents the given translation unit.""" - return conf.lib.clang_getTranslationUnitCursor(self) # type: ignore [no-any-return] + return conf.lib.clang_getTranslationUnitCursor(self) # type: ignore [no-any-return] @property def spelling(self) -> str: """Get the original translation unit source file name.""" - return conf.lib.clang_getTranslationUnitSpelling(self) # type: ignore [no-any-return] + return conf.lib.clang_getTranslationUnitSpelling(self) # type: ignore [no-any-return] def get_includes(self) -> Iterator[FileInclusion]: """ Return an iterable sequence of FileInclusion objects that describe the sequence of inclusions in a translation unit. The first object in @@ -3449,16 +3453,16 @@ ) @property def name(self) -> str: """Return the complete file and path name of the file.""" - return conf.lib.clang_getFileName(self) # type: ignore [no-any-return] + return conf.lib.clang_getFileName(self) # type: ignore [no-any-return] @property def time(self) -> int: """Return the last modification time of the file.""" - return conf.lib.clang_getFileTime(self) # type: ignore [no-any-return] + return conf.lib.clang_getFileTime(self) # type: ignore [no-any-return] def __str__(self) -> str: return self.name def __repr__(self) -> str: @@ -3533,16 +3537,16 @@ self.ccmds = ccmds @property def directory(self) -> str: """Get the working directory for this CompileCommand""" - return conf.lib.clang_CompileCommand_getDirectory(self.cmd) # type: ignore [no-any-return] + return conf.lib.clang_CompileCommand_getDirectory(self.cmd) # type: ignore [no-any-return] @property def filename(self) -> str: """Get the working filename for this CompileCommand""" - return conf.lib.clang_CompileCommand_getFilename(self.cmd) # type: ignore [no-any-return] + return conf.lib.clang_CompileCommand_getFilename(self.cmd) # type: ignore [no-any-return] @property def arguments(self) -> Iterator[str]: """ Get an iterable object providing each argument in the @@ -3617,20 +3621,20 @@ def getCompileCommands(self, filename: StrPath) -> CompileCommands: """ 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( # type: ignore [no-any-return] + return conf.lib.clang_CompilationDatabase_getCompileCommands( # type: ignore [no-any-return] self, os.fspath(filename) ) def getAllCompileCommands(self) -> CompileCommands: """ Get an iterable object providing all the CompileCommands available from the database. """ - return conf.lib.clang_CompilationDatabase_getAllCompileCommands(self) # type: ignore [no-any-return] + return conf.lib.clang_CompilationDatabase_getAllCompileCommands(self) # type: ignore [no-any-return] class Token(Structure): """Represents a single token from the preprocessor. @@ -3647,26 +3651,26 @@ def spelling(self) -> str: """The spelling of this token. This is the textual representation of the token in source. """ - return conf.lib.clang_getTokenSpelling(self._tu, self) # type: ignore [no-any-return] + return conf.lib.clang_getTokenSpelling(self._tu, self) # type: ignore [no-any-return] @property def kind(self) -> TokenKind: """Obtain the TokenKind of the current token.""" return TokenKind.from_value(conf.lib.clang_getTokenKind(self)) @property def location(self) -> SourceLocation: """The SourceLocation this Token occurs at.""" - return conf.lib.clang_getTokenLocation(self._tu, self) # type: ignore [no-any-return] + return conf.lib.clang_getTokenLocation(self._tu, self) # type: ignore [no-any-return] @property def extent(self) -> SourceRange: """The SourceRange this Token occupies.""" - return conf.lib.clang_getTokenExtent(self._tu, self) # type: ignore [no-any-return] + return conf.lib.clang_getTokenExtent(self._tu, self) # type: ignore [no-any-return] @property def cursor(self) -> Cursor: """The Cursor this Token corresponds to.""" cursor = Cursor() @@ -3724,11 +3728,11 @@ Save all changed files to disk. Returns 1 if any files were not saved successfully, returns 0 otherwise. """ - return conf.lib.clang_CXRewriter_overwriteChangedFiles(self) # type: ignore [no-any-return] + return conf.lib.clang_CXRewriter_overwriteChangedFiles(self) # type: ignore [no-any-return] def write_main_file_to_stdout(self) -> None: """ Writes the main file to stdout. """ `````````` </details> https://github.com/llvm/llvm-project/pull/78114 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits