openepd 4.1.0__tar.gz → 4.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openepd-4.1.0 → openepd-4.3.0}/PKG-INFO +8 -1
- {openepd-4.1.0 → openepd-4.3.0}/README.md +7 -0
- {openepd-4.1.0 → openepd-4.3.0}/pyproject.toml +1 -1
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/__version__.py +1 -1
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/base.py +22 -1
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/common.py +4 -1
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/finishes.py +0 -3
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/wood.py +0 -4
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/wood_joists.py +0 -2
- openepd-4.3.0/src/openepd/mypy/__init__.py +15 -0
- openepd-4.3.0/src/openepd/mypy/custom_pydantic_plugin.py +91 -0
- {openepd-4.1.0 → openepd-4.3.0}/LICENSE +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/base_sync_client.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/category/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/category/dto.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/category/sync_api.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/common.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/dto/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/dto/base.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/dto/common.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/dto/meta.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/dto/mf.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/dto/params.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/epd/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/epd/dto.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/epd/sync_api.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/errors.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/pcr/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/pcr/sync_api.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/sync_client.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/test/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/api/utils.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/bundle/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/bundle/base.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/bundle/model.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/bundle/reader.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/bundle/writer.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/compat/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/compat/compat_functional_validators.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/compat/pydantic.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/category.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/common.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/epd.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/factory.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/lcia.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/org.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/pcr.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/README.md +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/asphalt.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/base.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/concrete.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/accessories.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/aggregates.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/aluminium.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/asphalt.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/bulk_materials.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/cast_decks_and_underlayment.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/cladding.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/cmu.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/concrete.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/conveying_equipment.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/electrical.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/electrical_transmission_and_distribution_equipment.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/electricity.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/enums.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/fire_and_smoke_protection.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/furnishings.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/grouting.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/manufacturing_inputs.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/masonry.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/material_handling.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/mechanical.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/mechanical_insulation.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/network_infrastructure.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/openings.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/other_electrical_equipment.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/other_materials.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/plumbing.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/precast_concrete.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/sheathing.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/steel.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/thermal_moisture_protection.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/utility_piping.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/standard.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/validation/__init__.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/validation/common.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/validation/numbers.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/validation/quantity.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/versioning.py +0 -0
- {openepd-4.1.0 → openepd-4.3.0}/src/openepd/py.typed +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: openepd
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.3.0
|
4
4
|
Summary: Python library to work with OpenEPD format
|
5
5
|
Home-page: https://github.com/cchangelabs/openepd
|
6
6
|
License: Apache-2.0
|
@@ -144,6 +144,13 @@ with DefaultBundleWriter("my-bundle.epb") as writer, open("test-pcr.pdf", "rb")
|
|
144
144
|
writer.write_blob_asset(pcr_pdf_file, "application/pdf", pcr_asset, RelType.Pdf)
|
145
145
|
```
|
146
146
|
|
147
|
+
### Mypy
|
148
|
+
|
149
|
+
OpenEPD uses a small modification to standard pydantic models (see PydanticClassAttributeExposeModelMetaclass). Mypy,
|
150
|
+
in order to work correctly, requires a modified pydantic plugin. To enable it, add an
|
151
|
+
`openepd.mypy.custom_pydantic_plugin` to list of mypy plugins in your `pyproject.toml` or other mypy-related config
|
152
|
+
file. See [Mypy configuration](https://mypy.readthedocs.io/en/stable/extending_mypy.html)
|
153
|
+
|
147
154
|
# Credits
|
148
155
|
|
149
156
|
This library has been written and maintained by [C-Change Labs](https://c-change-labs.com/).
|
@@ -118,6 +118,13 @@ with DefaultBundleWriter("my-bundle.epb") as writer, open("test-pcr.pdf", "rb")
|
|
118
118
|
writer.write_blob_asset(pcr_pdf_file, "application/pdf", pcr_asset, RelType.Pdf)
|
119
119
|
```
|
120
120
|
|
121
|
+
### Mypy
|
122
|
+
|
123
|
+
OpenEPD uses a small modification to standard pydantic models (see PydanticClassAttributeExposeModelMetaclass). Mypy,
|
124
|
+
in order to work correctly, requires a modified pydantic plugin. To enable it, add an
|
125
|
+
`openepd.mypy.custom_pydantic_plugin` to list of mypy plugins in your `pyproject.toml` or other mypy-related config
|
126
|
+
file. See [Mypy configuration](https://mypy.readthedocs.io/en/stable/extending_mypy.html)
|
127
|
+
|
121
128
|
# Credits
|
122
129
|
|
123
130
|
This library has been written and maintained by [C-Change Labs](https://c-change-labs.com/).
|
@@ -56,7 +56,28 @@ def modify_pydantic_schema(schema_dict: dict, cls: type) -> dict:
|
|
56
56
|
return schema_dict
|
57
57
|
|
58
58
|
|
59
|
-
class
|
59
|
+
class PydanticClassAttributeExposeModelMetaclass(pyd.main.ModelMetaclass):
|
60
|
+
"""
|
61
|
+
Extension of the pydantic's ModelMetaclass which restores class attribute lookup for fields.
|
62
|
+
|
63
|
+
In pydantic, while the model fields are defined in the model as class-level attributes, in runtime they disappear
|
64
|
+
due to ModelMetaclass logic. ModelMetaclass takes the defined attributes, removes them from class dict and puts
|
65
|
+
into a special __fields__ attribute to avoid naming conflict.
|
66
|
+
|
67
|
+
We would like to be able to access the attributes via dot notation in the runtimes, since it makes refactoring
|
68
|
+
easier.
|
69
|
+
|
70
|
+
This class exposes the original fields when accessed via class name. For example, one can call `Pcr.name` and get
|
71
|
+
`ModelField`, in addition to calling `pcr.__fields__` on an instance.
|
72
|
+
"""
|
73
|
+
|
74
|
+
def __getattr__(cls, name: str) -> Any:
|
75
|
+
if name in cls.__fields__:
|
76
|
+
return cls.__fields__[name]
|
77
|
+
return getattr(super, name)
|
78
|
+
|
79
|
+
|
80
|
+
class BaseOpenEpdSchema(pyd.BaseModel, metaclass=PydanticClassAttributeExposeModelMetaclass):
|
60
81
|
"""Base class for all OpenEPD models."""
|
61
82
|
|
62
83
|
ext: dict[str, AnySerializable] | None = pyd.Field(alias="ext", default=None)
|
@@ -13,6 +13,7 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
|
+
from openepd.compat.pydantic import pyd
|
16
17
|
from openepd.model.base import BaseOpenEpdSchema
|
17
18
|
from openepd.model.org import OrgRef
|
18
19
|
|
@@ -20,4 +21,6 @@ from openepd.model.org import OrgRef
|
|
20
21
|
class HasForestPracticesCertifiers(BaseOpenEpdSchema):
|
21
22
|
"""An interface for models which are linked to forest practices certifiers."""
|
22
23
|
|
23
|
-
forest_practices_certifiers: list[OrgRef] | None
|
24
|
+
forest_practices_certifiers: list[OrgRef] | None = pyd.Field(
|
25
|
+
default=None, description="List of organizations that certify forest practices."
|
26
|
+
)
|
@@ -14,7 +14,6 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
from openepd.compat.pydantic import pyd
|
17
|
-
from openepd.model.org import OrgRef
|
18
17
|
from openepd.model.specs.base import BaseOpenEpdHierarchicalSpec
|
19
18
|
from openepd.model.specs.generated.common import HasForestPracticesCertifiers
|
20
19
|
from openepd.model.specs.generated.enums import (
|
@@ -179,7 +178,6 @@ class WoodFlooringV1(BaseOpenEpdHierarchicalSpec, HasForestPracticesCertifiers):
|
|
179
178
|
thickness: LengthMmStr | None = pyd.Field(default=None, description="", example="10 mm")
|
180
179
|
timber_species: WoodFlooringTimberSpecies | None = pyd.Field(default=None, description="", example="Oak")
|
181
180
|
fabrication: WoodFlooringFabrication | None = pyd.Field(default=None, description="", example="Solid hardwood")
|
182
|
-
forest_practices_certifiers: list[OrgRef] | None = pyd.Field(default=None, description="")
|
183
181
|
|
184
182
|
|
185
183
|
class AcousticalCeilingsV1(BaseOpenEpdHierarchicalSpec):
|
@@ -425,7 +423,6 @@ class DeckingBoardsV1(BaseOpenEpdHierarchicalSpec, HasForestPracticesCertifiers)
|
|
425
423
|
# Own fields:
|
426
424
|
timber_species: SawnTimberSpecies | None = pyd.Field(default=None, description="", example="Alaska Cedar")
|
427
425
|
fabrication: AllFabrication | None = pyd.Field(default=None, description="", example="LVL")
|
428
|
-
forest_practices_certifiers: list[OrgRef] | None = pyd.Field(default=None, description="")
|
429
426
|
weather_exposed: bool | None = pyd.Field(default=None, description="", example=True)
|
430
427
|
fire_retardant: bool | None = pyd.Field(default=None, description="", example=True)
|
431
428
|
decay_resistant: bool | None = pyd.Field(default=None, description="", example=True)
|
@@ -14,7 +14,6 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
from openepd.compat.pydantic import pyd
|
17
|
-
from openepd.model.org import OrgRef
|
18
17
|
from openepd.model.specs.base import BaseOpenEpdHierarchicalSpec
|
19
18
|
from openepd.model.specs.generated.common import HasForestPracticesCertifiers
|
20
19
|
from openepd.model.specs.generated.enums import (
|
@@ -154,9 +153,6 @@ class WoodV1(BaseOpenEpdHierarchicalSpec, HasForestPracticesCertifiers):
|
|
154
153
|
default=None, description="Timber species", example="Alaska Cedar"
|
155
154
|
)
|
156
155
|
fabrication: AllFabrication | None = pyd.Field(default=None, description="Timber fabrication", example="LVL")
|
157
|
-
forest_practices_certifiers: list[OrgRef] | None = pyd.Field(
|
158
|
-
default=None, description="List of organizations that certify forest practices."
|
159
|
-
)
|
160
156
|
weather_exposed: bool | None = pyd.Field(default=None, description="Weather exposed", example=True)
|
161
157
|
fire_retardant: bool | None = pyd.Field(default=None, description="Fire retardant", example=True)
|
162
158
|
decay_resistant: bool | None = pyd.Field(default=None, description="Decay resistant", example=True)
|
@@ -14,7 +14,6 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
from openepd.compat.pydantic import pyd
|
17
|
-
from openepd.model.org import OrgRef
|
18
17
|
from openepd.model.specs.base import BaseOpenEpdHierarchicalSpec
|
19
18
|
from openepd.model.specs.generated.common import HasForestPracticesCertifiers
|
20
19
|
from openepd.model.specs.generated.enums import AllFabrication, AllTimberSpecies
|
@@ -33,7 +32,6 @@ class WoodJoistsV1(BaseOpenEpdHierarchicalSpec, HasForestPracticesCertifiers):
|
|
33
32
|
# Own fields:
|
34
33
|
timber_species: AllTimberSpecies | None = pyd.Field(default=None, description="", example="Alaska Cedar")
|
35
34
|
fabrication: AllFabrication | None = pyd.Field(default=None, description="", example="LVL")
|
36
|
-
forest_practices_certifiers: list[OrgRef] | None = pyd.Field(default=None, description="")
|
37
35
|
weather_exposed: bool | None = pyd.Field(default=None, description="", example=True)
|
38
36
|
fire_retardant: bool | None = pyd.Field(default=None, description="", example=True)
|
39
37
|
decay_resistant: bool | None = pyd.Field(default=None, description="", example=True)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2024 by C Change Labs Inc. www.c-change-labs.com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2024 by C Change Labs Inc. www.c-change-labs.com
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
from collections.abc import Callable
|
18
|
+
|
19
|
+
from mypy.nodes import AssignmentStmt, CallExpr, MemberExpr, TypeInfo
|
20
|
+
from mypy.plugin import ClassDefContext
|
21
|
+
import pydantic.mypy
|
22
|
+
from pydantic.mypy import (
|
23
|
+
MODEL_METACLASS_FULLNAME,
|
24
|
+
ModelConfigData,
|
25
|
+
PydanticModelClassVar,
|
26
|
+
PydanticModelField,
|
27
|
+
PydanticModelTransformer,
|
28
|
+
PydanticPlugin,
|
29
|
+
)
|
30
|
+
|
31
|
+
# Using this plugin fixes the issue.
|
32
|
+
|
33
|
+
CUSTOM_OPENEPD_MODEL_METACLASS_FULLNAME = "openepd.model.base.PydanticClassAttributeExposeModelMetaclass"
|
34
|
+
MODEL_METACLASSES_FULL_NAMES = (MODEL_METACLASS_FULLNAME, CUSTOM_OPENEPD_MODEL_METACLASS_FULLNAME)
|
35
|
+
|
36
|
+
DECORATOR_FULLNAMES = pydantic.mypy.DECORATOR_FULLNAMES | {
|
37
|
+
"pydantic.v1.class_validators.validator",
|
38
|
+
}
|
39
|
+
|
40
|
+
|
41
|
+
class CustomPydanticModelTransformer(PydanticModelTransformer):
|
42
|
+
"""Extension of the mypy/pydantic model transformer which also understands validator definitions via v1 compat."""
|
43
|
+
|
44
|
+
def collect_field_or_class_var_from_stmt(
|
45
|
+
self, stmt: AssignmentStmt, model_config: ModelConfigData, class_vars: dict[str, PydanticModelClassVar]
|
46
|
+
) -> PydanticModelField | PydanticModelClassVar | None:
|
47
|
+
"""Extend implementation of the original Pydantic method with one more case for validator."""
|
48
|
+
if not stmt.new_syntax and (
|
49
|
+
isinstance(stmt.rvalue, CallExpr)
|
50
|
+
and isinstance(stmt.rvalue.callee, CallExpr)
|
51
|
+
and isinstance(stmt.rvalue.callee.callee, MemberExpr)
|
52
|
+
and stmt.rvalue.callee.callee.fullname in DECORATOR_FULLNAMES
|
53
|
+
):
|
54
|
+
# Required to detect compat-imported v1 validators and not treat them as fields.
|
55
|
+
return None
|
56
|
+
return super().collect_field_or_class_var_from_stmt(stmt, model_config, class_vars)
|
57
|
+
|
58
|
+
|
59
|
+
class CustomMetaclassPydanticPlugin(PydanticPlugin):
|
60
|
+
"""
|
61
|
+
Custom metaclass pydantic plugin.
|
62
|
+
|
63
|
+
Extends a standard pydantic mypy plugin, and adds certain behaviours required for us:
|
64
|
+
1. Support for a non-standard metaclass for pydantic models. We use it allow for access via Class.field notation
|
65
|
+
2. Support for our modified compat import of pydantic v1 when using this metaclass.
|
66
|
+
"""
|
67
|
+
|
68
|
+
def get_metaclass_hook(self, fullname: str) -> Callable[[ClassDefContext], None] | None:
|
69
|
+
"""Update Pydantic `ModelMetaclass` definition."""
|
70
|
+
if fullname in MODEL_METACLASSES_FULL_NAMES:
|
71
|
+
return self._pydantic_model_metaclass_marker_callback
|
72
|
+
return None
|
73
|
+
|
74
|
+
def get_base_class_hook(self, fullname: str) -> Callable[[ClassDefContext], bool] | None: # type: ignore
|
75
|
+
"""Update Pydantic model class."""
|
76
|
+
sym = self.lookup_fully_qualified(fullname)
|
77
|
+
if sym and isinstance(sym.node, TypeInfo): # pragma: no branch
|
78
|
+
# No branching may occur if the mypy cache has not been cleared
|
79
|
+
if any(base.fullname in ["pydantic.main.BaseModel", "pydantic.v1.main.BaseModel"] for base in sym.node.mro):
|
80
|
+
return self._pydantic_model_class_maker_callback
|
81
|
+
return None
|
82
|
+
|
83
|
+
def _pydantic_model_class_maker_callback(self, ctx: ClassDefContext) -> bool:
|
84
|
+
# extended to replace the mypy-pydantic transformer with our custom transformer - see validator note.
|
85
|
+
transformer = CustomPydanticModelTransformer(ctx.cls, ctx.reason, ctx.api, self.plugin_config)
|
86
|
+
return transformer.transform()
|
87
|
+
|
88
|
+
|
89
|
+
def plugin(version: str):
|
90
|
+
"""Entry point to the mypy plugin."""
|
91
|
+
return CustomMetaclassPydanticPlugin
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/cast_decks_and_underlayment.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/fire_and_smoke_protection.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/other_electrical_equipment.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{openepd-4.1.0 → openepd-4.3.0}/src/openepd/model/specs/generated/thermal_moisture_protection.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|