Versioned Documents¶
Document types for each EnergyPlus release, the check that narrows a document to one, and the types of the release arguments the loaders take. See Typed for a Release for how to use them.
idfkit.versioned
¶
Release document types¶
Every supported release has a document type, a range type from it onward and a range type before it. They are generated, one per release, and differ only in the release they name, so they are summarised here rather than rendered one by one.
| Name | A document of | Example |
|---|---|---|
IDFDocumentV<major>_<minor> |
exactly that release | IDFDocumentV9_4 |
IDFDocumentSince<major>_<minor> |
that release or any later one | IDFDocumentSince22_1 |
IDFDocumentBefore<major>_<minor> |
any release earlier than that one | IDFDocumentBefore24_1 |
The releases run from 8.9 to 26.2, the ones in Versions. IDFDocumentV26_2, the
latest, is IDFDocument itself. IDFDocumentSince8_9 covers every
release, and there is no IDFDocumentBefore8_9.
For a type checker each IDFDocumentV<major>_<minor> is a class carrying that release's object
types and fields; at run time it is a stand-in that as_version
checks against. A range type is the union of the releases it covers.
idfkit.versioned.AnyIDFDocument = IDFDocumentAllVersions[Strict]
module-attribute
¶
A document of any supported EnergyPlus version.
IDFDocument, typed for the latest release, and every older release's type in idfkit.versioned derive from it, so annotate with it to accept a document whatever its version. Through it, a document offers what every supported version has: the object types present in all of them, each typed as all of them declare it, so a field whose choices changed between releases reads as the union of them, accepts only their intersection, and a field some release lacks is not offered.
"Space" in doc does not change this type: it is true when the document holds a Space, and
false for a release without the type and for one that has it but holds none, so it says nothing
about the release. Narrow with idfkit.versioned.as_version to reach what only some releases
have.
idfkit.versioned.as_version(doc, document_type=None, *, since=None, before=None)
¶
Type doc as a document of the EnergyPlus version document_type stands for, or one of several.
Or, given since and/or before instead, as a document of any supported release from since on and before before.
The stub in versioned.pyi documents this function; this is its run-time check.
Source code in idfkit/_document_types.py
idfkit.versioned.DocumentTypeTarget = type[AnyIDFDocument] | tuple[type[AnyIDFDocument], Unpack[tuple[type[AnyIDFDocument], ...]]]
module-attribute
¶
idfkit.versioned.ReleaseBound = type[AnyIDFDocument] | str | tuple[int, int] | tuple[int, int, int]
module-attribute
¶
One end of a range of releases, as since= and before= take it.
A release's document type (IDFDocumentV9_6), its number ("9.6") or its version tuple
((9, 6) or (9, 6, 0)). since= includes the release it names and before= excludes it.
idfkit.versioned.ReleaseDocumentT = release_type_var('ReleaseDocumentT', IDFDocumentV8_9, IDFDocumentV9_0, IDFDocumentV9_1, IDFDocumentV9_2, IDFDocumentV9_3, IDFDocumentV9_4, IDFDocumentV9_5, IDFDocumentV9_6, IDFDocumentV22_1, IDFDocumentV22_2, IDFDocumentV23_1, IDFDocumentV23_2, IDFDocumentV24_1, IDFDocumentV24_2, IDFDocumentV25_1, IDFDocumentV25_2, IDFDocumentV26_1, IDFDocumentV26_2)
module-attribute
¶
A type variable that is exactly one release's document type.
Constrained to IDFDocumentV8_9 ... IDFDocument, so type[ReleaseDocumentT] accepts one
release's type and refuses AnyIDFDocument, which names no single release. A union of release
types names none either: mypy refuses it, but pyright tries each member against the constraints
and accepts it, so check at run time too. idfkit.migration.migrate takes its target this
way, and raises TypeError for a union.