Skip to content

Commit b758fe0

Browse files
committed
chore: code cleanup, ci fixes
1 parent 67bab94 commit b758fe0

File tree

102 files changed

+1528
-5322
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1528
-5322
lines changed

.github/workflows/python-publish.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
3838
- name: Generate models
3939
run: |
40-
python scripts/generate_models.py
40+
python run.py all
4141
4242
- name: Run tests
4343
run: |
@@ -78,15 +78,21 @@ jobs:
7878
mkdir -p /tmp/check-sdist
7979
tar -xf dist/*.tar.gz -C /tmp/check-sdist
8080
MODEL_COUNT=$(find /tmp/check-sdist -name "*.py" | grep models | wc -l)
81+
ENUM_COUNT=$(find /tmp/check-sdist -name "*.py" | grep enums | wc -l)
8182
echo "Source distribution contains $MODEL_COUNT model files"
82-
if [ "$MODEL_COUNT" -lt 900 ]; then
83+
echo "Source distribution contains $ENUM_COUNT enum files"
84+
if [ "$MODEL_COUNT" -lt 800 ]; then
8385
echo "ERROR: Not enough model files in source distribution"
8486
exit 1
8587
fi
88+
if [ "$ENUM_COUNT" -lt 75 ]; then
89+
echo "ERROR: Not enough enum files in source distribution"
90+
exit 1
91+
fi
8692
8793
# Install and verify the wheel
8894
pip install dist/*.whl
89-
python -c "import msgspec_schemaorg.models; count = len(msgspec_schemaorg.models.__all__); print(f'Wheel contains {count} importable models'); assert count > 900, 'Not enough models'"
95+
python -c "import msgspec_schemaorg.models; count = len(msgspec_schemaorg.models.__all__); print(f'Wheel contains {count} importable models'); assert count > 800, 'Not enough models'"
9096
9197
- name: Upload distributions
9298
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,6 @@ Thumbs.db
206206
ehthumbs.db
207207
Desktop.ini
208208
msgspec_schemaorg/models/**/*.py
209-
!msgspec_schemaorg/models/**/__*.py
209+
!msgspec_schemaorg/models/**/__*.py
210+
msgspec_schemaorg/enums/**/*.py
211+
!msgspec_schemaorg/enums/**/__*.py

examples/enum_example.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import json
77
import msgspec
88
import inspect
9-
from msgspec_schemaorg.enums.intangible import DeliveryMethod, MediaManipulationRatingEnumeration
9+
from msgspec_schemaorg.enums import DeliveryMethod, MediaManipulationRatingEnumeration
1010
from msgspec_schemaorg.models import Offer, Person, MediaReview
1111

1212
# Using enums for property values
1313
offer = Offer(
14-
name="Fast Delivery Package",
14+
name="Fast Delivery Package",
1515
price=15.99,
1616
priceCurrency="USD",
1717
availableDeliveryMethod=DeliveryMethod.LockerDelivery,
@@ -25,14 +25,14 @@
2525

2626
# Using multiple enum values in a list
2727
offer_multi = Offer(
28-
name="Flexible Delivery Package",
28+
name="Flexible Delivery Package",
2929
price=19.99,
3030
priceCurrency="USD",
3131
availableDeliveryMethod=[
3232
DeliveryMethod.LockerDelivery,
3333
DeliveryMethod.OnSitePickup,
34-
DeliveryMethod.ParcelService
35-
]
34+
DeliveryMethod.ParcelService,
35+
],
3636
)
3737

3838
# Print the offer with multiple delivery methods
@@ -55,14 +55,16 @@
5555
print("Notable metadata fields:")
5656
print(f" - ID: schema:ParcelService")
5757
print(f" - Label: ParcelService")
58-
print(f" - Comment: A private parcel service as the delivery mode available for a certain offer.")
58+
print(
59+
f" - Comment: A private parcel service as the delivery mode available for a certain offer."
60+
)
5961
print()
6062

6163
# Creating a MediaReview with a rating enumeration
6264
review = MediaReview(
6365
name="Image Analysis",
6466
author=Person(name="Media Reviewer"),
65-
mediaAuthenticityCategory=MediaManipulationRatingEnumeration.OriginalMediaContent
67+
mediaAuthenticityCategory=MediaManipulationRatingEnumeration.OriginalMediaContent,
6668
)
6769

6870
# Print the media review
@@ -71,4 +73,4 @@
7173
print(json.dumps(json.loads(review_json), indent=2))
7274
print()
7375

74-
print("Example completed successfully!")
76+
print("Example completed successfully!")

msgspec_schemaorg/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
"enums",
1414
]
1515

16+
1617
# These imports are deferred to avoid circular dependencies when using just one part
1718
def __getattr__(name):
1819
if name == "models":
1920
from . import models as _models
21+
2022
globals()["models"] = _models
2123
return _models
2224
elif name == "enums":
2325
from . import enums as _enums
26+
2427
globals()["enums"] = _enums
2528
return _enums
2629
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")

msgspec_schemaorg/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Base classes for Schema.org models with JSON-LD compatibility.
33
"""
4+
45
from __future__ import annotations
56
from typing import Any, Dict, List, Optional, Union
67
import msgspec
@@ -10,16 +11,17 @@
1011
class SchemaOrgBase(msgspec.Struct, frozen=True, omit_defaults=True):
1112
"""
1213
Base class for all Schema.org models with JSON-LD fields.
13-
14+
1415
This class provides the standard JSON-LD fields (@id, @type, @context, etc.)
1516
that are used to represent linked data. All Schema.org model classes
1617
inherit from this base.
17-
18+
1819
JSON-LD fields are aliased using msgspec's field renaming to ensure
1920
that the serialized output uses the @ prefix.
2021
"""
22+
2123
id: Optional[str] = field(default=None, name="@id")
2224
context: Optional[Union[str, Dict[str, Any]]] = field(default=None, name="@context")
2325
# Note: type field is intentionally omitted since it will be provided by each class
2426
graph: Optional[List[Dict[str, Any]]] = field(default=None, name="@graph")
25-
reverse: Optional[Dict[str, Any]] = field(default=None, name="@reverse")
27+
reverse: Optional[Dict[str, Any]] = field(default=None, name="@reverse")

msgspec_schemaorg/cli.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

msgspec_schemaorg/enums/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
'PaymentMethodType',
6767
'PaymentStatusType',
6868
'PhysicalActivityCategory',
69+
'PhysicalExam',
6970
'PriceComponentTypeEnumeration',
7071
'PriceTypeEnumeration',
7172
'PurchaseType',

msgspec_schemaorg/enums/intangible/ActionStatusType.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

msgspec_schemaorg/enums/intangible/AdultOrientedEnumeration.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

msgspec_schemaorg/enums/intangible/BoardingPolicyType.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)