Skip to content

Model class initialization #705

@davaya

Description

@davaya

A question about code style. As an example the Agent class is:

@dataclass_with_properties
class Agent(Element):
    def __init__(
        self,
        spdx_id: str,
        creation_info: Optional[CreationInfo] = None,
        name: Optional[str] = None,
        summary: Optional[str] = None,
        description: Optional[str] = None,
        comment: Optional[str] = None,
        verified_using: List[IntegrityMethod] = None,
        external_reference: List[ExternalReference] = None,
        external_identifier: List[ExternalIdentifier] = None,
        extension: Optional[str] = None,
    ):
        verified_using = [] if verified_using is None else verified_using
        external_reference = [] if external_reference is None else external_reference
        external_identifier = [] if external_identifier is None else external_identifier
        check_types_and_set_values(self, locals())
  • Is there a reason verified_using, external_reference and external_identifier cannot be initialized as None?
  • If they do need to be empty arrays instead of None, can't that be done by making the argument default = []?
  • Is there a reason the core dataclasses are at the top level instead of in a core directory?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions