Skip to main content

Filing

Document model with a metaclass-defined schema. Core fields are fixed; subclasses add fields via Annotated[str, Field(...)].

Constructor

Filing(**kwargs) -> Filing
  • kwargs: Field values (e.g. source, name, checksum, format, is_zip). Omit id and created_at to have them auto-generated.
  • Raises: FilingRequiredError if a required field is missing or None; FilingValidationError / FieldValidationError on type mismatch; FieldImmutableError when reassigning an immutable field after init.

Identity and ID generation

  • ID hash fields: If any user-defined field uses Field(..., identifier=True), only those fields (sorted by name) are concatenated and hashed for auto-generated id. Otherwise, behavior matches identity fields below (backward compatible).
  • Identity fields: Core set source, name, is_zip, format plus all user-defined fields (excluding id, created_at, checksum). Used for deterministic id when no identifier=True fields exist.
  • id: If not provided, computed as SHA256(ID hash field values)[:32].
  • created_at: If not provided, set to datetime.now().

Instance methods

MethodReturnsDescription
to_dict()dict[str, Any]Flat dict of all fields; datetime → ISO string
get(key: str)AnyValue for key

Class methods

MethodReturnsDescription
from_dict(cls, data: dict) -> SelfFiling instanceRestore from dict; datetime strings are parsed. Raises same as constructor when keys/types invalid.

Attributes (core)

All filings have these fields. Required unless noted.

FieldTypeRequiredIndexedImmutableDescription
idstryesyesyesFiling ID (auto-generated from identity fields if omitted)
sourcestryesyesyesData source(例: "EDGAR", "EDINET"
checksumstryesyesnoSHA256 hex digest of content
namestryesyesyesFile name
is_zipboolyesyesnoWhether content is ZIP
formatstryesyesyesFormat / extension (e.g. xbrl, zip, pdf)
created_atdatetimeyesyesyesCreated timestamp (auto-generated if omitted)

Custom Filing subclasses

You can define your own Filing type by subclassing Filing and declaring additional fields with Annotated[str, Field(...)] (or other types). The metaclass handles schema registration, identity, and validation. Register your subclass on a FilingResolver (e.g. used by Catalog) so instances can be restored from storage.

組み込みサブクラス: EDINETFilingsource="EDINET"); EdgarArchiveFiling / EdgarBulkFiling / EdgarCompanyFactsFiling(いずれも source="EDGAR")。いずれも default_resolver に登録され、Catalog から復元可能。