Skip to content

Commit

Permalink
fix mypy;
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Sep 10, 2024
1 parent 061626a commit 435139e
Show file tree
Hide file tree
Showing 14 changed files with 446 additions and 457 deletions.
10 changes: 5 additions & 5 deletions generate/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1744,16 +1744,16 @@ def generateObjectTypeCode(
if "default" in property_schema:
if field_type == "str":
field_type += ' = "' + property_schema["default"] + '"'
elif isinstance(property_schema["default"], str):
field_type += (
' = "' + property_schema["default"] + '" # type: ignore'
)
elif "allOf" in property_schema:
field_type += (
" = "
+ field_type
+ '(**json.loads("""'
+ str(property_schema["default"])
+ '"""))'
+ " # type: ignore"
)
elif isinstance(property_schema["default"], str):
field_type += ' = "' + property_schema["default"] + '"'
else:
field_type += " = " + str(property_schema["default"])
else:
Expand Down
754 changes: 377 additions & 377 deletions kittycad.py.patch.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions kittycad/models/card_details.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from typing import Optional

from pydantic import BaseModel, ConfigDict
Expand All @@ -11,7 +10,7 @@ class CardDetails(BaseModel):

brand: Optional[str] = None

checks: PaymentMethodCardChecks = PaymentMethodCardChecks(**json.loads("""{}"""))
checks: PaymentMethodCardChecks = {} # type: ignore

country: Optional[str] = None

Expand Down
50 changes: 30 additions & 20 deletions kittycad/models/connection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import json
from typing import Dict

from pydantic import BaseModel, ConfigDict
Expand All @@ -17,11 +16,14 @@ class Connection(BaseModel):

auth_timeout: int = 0

cluster: Cluster = Cluster(
**json.loads(
"""{'addr': None, 'auth_timeout': 0, 'cluster_port': 0, 'name': '', 'tls_timeout': 0, 'urls': []}"""
)
)
cluster: Cluster = {
"addr": None,
"auth_timeout": 0,
"cluster_port": 0,
"name": "",
"tls_timeout": 0,
"urls": [],
} # type: ignore

config_load_time: datetime.datetime

Expand All @@ -31,11 +33,13 @@ class Connection(BaseModel):

cpu: float = 0.0

gateway: Gateway = Gateway(
**json.loads(
"""{'auth_timeout': 0, 'host': '', 'name': '', 'port': 0, 'tls_timeout': 0}"""
)
)
gateway: Gateway = {
"auth_timeout": 0,
"host": "",
"name": "",
"port": 0,
"tls_timeout": 0,
} # type: ignore

git_commit: str = ""

Expand All @@ -59,15 +63,21 @@ class Connection(BaseModel):

in_msgs: int = 0

jetstream: Jetstream = Jetstream(
**json.loads(
"""{'config': {'domain': '', 'max_memory': 0, 'max_storage': 0, 'store_dir': ''}, 'meta': {'cluster_size': 0, 'leader': '', 'name': ''}, 'stats': {'accounts': 0, 'api': {'errors': 0, 'inflight': 0, 'total': 0}, 'ha_assets': 0, 'memory': 0, 'reserved_memory': 0, 'reserved_store': 0, 'store': 0}}"""
)
)

leaf: LeafNode = LeafNode(
**json.loads("""{'auth_timeout': 0, 'host': '', 'port': 0, 'tls_timeout': 0}""")
)
jetstream: Jetstream = {
"config": {"domain": "", "max_memory": 0, "max_storage": 0, "store_dir": ""},
"meta": {"cluster_size": 0, "leader": "", "name": ""},
"stats": {
"accounts": 0,
"api": {"errors": 0, "inflight": 0, "total": 0},
"ha_assets": 0,
"memory": 0,
"reserved_memory": 0,
"reserved_store": 0,
"store": 0,
},
} # type: ignore

leaf: LeafNode = {"auth_timeout": 0, "host": "", "port": 0, "tls_timeout": 0} # type: ignore

leafnodes: int = 0

Expand Down
3 changes: 1 addition & 2 deletions kittycad/models/customer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import json
from typing import Dict, Optional

from pydantic import BaseModel, ConfigDict
Expand All @@ -17,7 +16,7 @@ class Customer(BaseModel):

created_at: datetime.datetime

currency: Currency = Currency(**json.loads("""usd"""))
currency: Currency = "usd" # type: ignore

delinquent: bool = False

Expand Down
3 changes: 1 addition & 2 deletions kittycad/models/invoice.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import json
from typing import Dict, List, Optional

from pydantic import BaseModel, ConfigDict
Expand All @@ -25,7 +24,7 @@ class Invoice(BaseModel):

created_at: datetime.datetime

currency: Currency = Currency(**json.loads("""usd"""))
currency: Currency = "usd" # type: ignore

customer_email: Optional[str] = None

Expand Down
3 changes: 1 addition & 2 deletions kittycad/models/invoice_line_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from typing import Dict, Optional

from pydantic import BaseModel, ConfigDict
Expand All @@ -11,7 +10,7 @@ class InvoiceLineItem(BaseModel):

amount: float = 0.0

currency: Currency = Currency(**json.loads("""usd"""))
currency: Currency = "usd" # type: ignore

description: Optional[str] = None

Expand Down
35 changes: 18 additions & 17 deletions kittycad/models/jetstream.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

from pydantic import BaseModel, ConfigDict

from ..models.jetstream_config import JetstreamConfig
Expand All @@ -10,20 +8,23 @@
class Jetstream(BaseModel):
"""Jetstream information."""

config: JetstreamConfig = JetstreamConfig(
**json.loads(
"""{'domain': '', 'max_memory': 0, 'max_storage': 0, 'store_dir': ''}"""
)
)

meta: MetaClusterInfo = MetaClusterInfo(
**json.loads("""{'cluster_size': 0, 'leader': '', 'name': ''}""")
)

stats: JetstreamStats = JetstreamStats(
**json.loads(
"""{'accounts': 0, 'api': {'errors': 0, 'inflight': 0, 'total': 0}, 'ha_assets': 0, 'memory': 0, 'reserved_memory': 0, 'reserved_store': 0, 'store': 0}"""
)
)
config: JetstreamConfig = {
"domain": "",
"max_memory": 0,
"max_storage": 0,
"store_dir": "",
} # type: ignore

meta: MetaClusterInfo = {"cluster_size": 0, "leader": "", "name": ""} # type: ignore

stats: JetstreamStats = {
"accounts": 0,
"api": {"errors": 0, "inflight": 0, "total": 0},
"ha_assets": 0,
"memory": 0,
"reserved_memory": 0,
"reserved_store": 0,
"store": 0,
} # type: ignore

model_config = ConfigDict(protected_namespaces=())
6 changes: 1 addition & 5 deletions kittycad/models/jetstream_stats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

from pydantic import BaseModel, ConfigDict

from ..models.jetstream_api_stats import JetstreamApiStats
Expand All @@ -10,9 +8,7 @@ class JetstreamStats(BaseModel):

accounts: int = 0

api: JetstreamApiStats = JetstreamApiStats(
**json.loads("""{'errors': 0, 'inflight': 0, 'total': 0}""")
)
api: JetstreamApiStats = {"errors": 0, "inflight": 0, "total": 0} # type: ignore

ha_assets: int = 0

Expand Down
5 changes: 1 addition & 4 deletions kittycad/models/kcl_code_completion_request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from typing import List, Optional

from pydantic import BaseModel, ConfigDict
Expand All @@ -9,9 +8,7 @@
class KclCodeCompletionRequest(BaseModel):
"""A request to generate KCL code completions."""

extra: KclCodeCompletionParams = KclCodeCompletionParams(
**json.loads("""{'language': '', 'trim_by_indentation': False}""")
)
extra: KclCodeCompletionParams = {"language": "", "trim_by_indentation": False} # type: ignore

max_tokens: Optional[int] = None

Expand Down
3 changes: 1 addition & 2 deletions kittycad/models/modeling_cmd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from typing import List, Literal, Optional, Union

from pydantic import BaseModel, ConfigDict, Field, RootModel
Expand Down Expand Up @@ -675,7 +674,7 @@ class solid3d_get_prev_adjacent_edge(BaseModel):
class solid3d_fillet_edge(BaseModel):
"""Fillets the given edge with the specified radius."""

cut_type: CutType = CutType(**json.loads("""fillet"""))
cut_type: CutType = "fillet" # type: ignore

edge_id: str

Expand Down
16 changes: 7 additions & 9 deletions kittycad/models/transform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

from pydantic import BaseModel, ConfigDict

from ..models.point3d import Point3d
Expand All @@ -11,14 +9,14 @@ class Transform(BaseModel):

replicate: bool = True

rotation: Rotation = Rotation(
**json.loads(
"""{'angle': {'unit': 'degrees', 'value': 0.0}, 'axis': {'x': 0.0, 'y': 0.0, 'z': 1.0}, 'origin': {'type': 'local'}}"""
)
)
rotation: Rotation = {
"angle": {"unit": "degrees", "value": 0.0},
"axis": {"x": 0.0, "y": 0.0, "z": 1.0},
"origin": {"type": "local"},
} # type: ignore

scale: Point3d = Point3d(**json.loads("""{'x': 1.0, 'y': 1.0, 'z': 1.0}"""))
scale: Point3d = {"x": 1.0, "y": 1.0, "z": 1.0} # type: ignore

translate: Point3d = Point3d(**json.loads("""{'x': 0.0, 'y': 0.0, 'z': 0.0}"""))
translate: Point3d = {"x": 0.0, "y": 0.0, "z": 0.0} # type: ignore

model_config = ConfigDict(protected_namespaces=())
6 changes: 1 addition & 5 deletions kittycad/models/zoo_product_subscriptions_org_request.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

from pydantic import BaseModel, ConfigDict

from ..models.modeling_app_organization_subscription_tier import (
Expand All @@ -10,8 +8,6 @@
class ZooProductSubscriptionsOrgRequest(BaseModel):
"""A struct of Zoo product subscriptions an organization can request."""

modeling_app: ModelingAppOrganizationSubscriptionTier = (
ModelingAppOrganizationSubscriptionTier(**json.loads("""team"""))
)
modeling_app: ModelingAppOrganizationSubscriptionTier = "team" # type: ignore

model_config = ConfigDict(protected_namespaces=())
6 changes: 1 addition & 5 deletions kittycad/models/zoo_product_subscriptions_user_request.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

from pydantic import BaseModel, ConfigDict

from ..models.modeling_app_individual_subscription_tier import (
Expand All @@ -10,8 +8,6 @@
class ZooProductSubscriptionsUserRequest(BaseModel):
"""A struct of Zoo product subscriptions a user can request."""

modeling_app: ModelingAppIndividualSubscriptionTier = (
ModelingAppIndividualSubscriptionTier(**json.loads("""free"""))
)
modeling_app: ModelingAppIndividualSubscriptionTier = "free" # type: ignore

model_config = ConfigDict(protected_namespaces=())

0 comments on commit 435139e

Please sign in to comment.