xsdata.codegen.handlers.attribute_type module

class xsdata.codegen.handlers.attribute_type.AttributeTypeHandler(container, dependencies=<factory>)[source]

Bases: xsdata.codegen.mixins.HandlerInterface

Minimize class attributes complexity by filtering and flattening types.

Parameters
container: xsdata.codegen.mixins.ContainerInterface
dependencies: Dict
process(target)[source]

Process the given class attributes and their types.

Ensure all types are unique.

Parameters

target (Class) –

process_type(target, attr, attr_type)[source]

Process attribute type, split process for xml schema and user defined types.

Ignore forward references to inner classes.

Parameters
classmethod process_native_type(attr, attr_type)[source]

Reset attribute type if the attribute has a pattern restriction as they are not yet supported.

Parameters
find_dependency(attr_type)[source]

Find dependency for the given attribute.

Avoid conflicts by search in order:
  1. Non element/complexType

  2. Non abstract

  3. anything

Parameters

attr_type (AttrType) –

Return type

Optional[Class]

process_inner_type(target, attr, attr_type)[source]

Process an attributes type that depends on an inner type.

If there is a matching simple type inner class copy the inner type attribute properties.

Parameters
process_dependency_type(target, attr, attr_type)[source]

Process an attributes type that depends on any global type.

Steps:
  1. Reset absent or dummy attribute types with a warning.

  2. Copy attribute properties from a simple type.

  3. Set circular flag for the rest non enumerations.

Parameters
classmethod copy_attribute_properties(source, target, attr, attr_type)[source]

Replace the given attribute type with the types of the single field source class.

Ignore enumerations and gracefully handle dump types with no attributes.

Raises

AnalyzerValueError if the source class has more than one attributes

Parameters
set_circular_flag(source, target, attr_type)[source]

Update circular reference flag.

Parameters
is_circular_dependency(source, target, seen)[source]

Check if any source dependencies recursively match the target class.

Parameters
Return type

bool

cached_dependencies(source)[source]

Returns from cache the source class dependencies as a collection of qualified names.

Parameters

source (Class) –

Return type

Tuple[str]

classmethod reset_attribute_type(attr_type)[source]

Reset the attribute type to native string.

Parameters

attr_type (AttrType) –

classmethod filter_types(types)[source]

Remove duplicate and invalid types.

Invalid:
  1. xs:error

  2. xs:anyType and xs:anySimpleType when there are other types present

Parameters

types (List[AttrType]) –

Return type

List[AttrType]