Skip to content

Commit 855843a

Browse files
committed
Update for changes to ducktools-classbuilder
1 parent aa632e3 commit 855843a

File tree

3 files changed

+190
-153
lines changed

3 files changed

+190
-153
lines changed

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ requires = [
66
build-backend = "setuptools.build_meta"
77

88
[project]
9-
name="ducktools-env"
10-
description="Virtual environment management tools and application bundle builder"
9+
name = "ducktools-env"
10+
description = "Virtual environment management tools and application bundle builder"
1111
authors = [
12-
{ name="David C Ellis" },
12+
{ name = "David C Ellis" },
1313
]
14-
readme="README.md"
14+
readme = "README.md"
1515
requires-python = ">=3.10"
1616
dependencies = [
17-
"ducktools-classbuilder>=0.7.1",
17+
"ducktools-classbuilder>=0.12.3",
1818
"ducktools-lazyimporter>=0.7.0",
1919
"ducktools-scriptmetadata>=0.2.0",
2020
"ducktools-pythonfinder>=0.8.1",
@@ -56,7 +56,7 @@ __version_tuple__ = {version_tuple}
5656
"""
5757

5858
[tool.pytest.ini_options]
59-
addopts= "--cov=src/ --cov-report=term-missing --cov-report xml:cov.xml"
59+
addopts = "--cov=src/ --cov-report=term-missing --cov-report xml:cov.xml"
6060
testpaths = [
6161
"tests",
6262
]

src/ducktools/env/_sqlclasses.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# ducktools.env
22
# MIT License
3-
#
3+
#
44
# Copyright (c) 2024 David C Ellis
5-
#
5+
#
66
# Permission is hereby granted, free of charge, to any person obtaining a copy
77
# of this software and associated documentation files (the "Software"), to deal
88
# in the Software without restriction, including without limitation the rights
99
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1010
# copies of the Software, and to permit persons to whom the Software is
1111
# furnished to do so, subject to the following conditions:
12-
#
12+
#
1313
# The above copyright notice and this permission notice shall be included in all
1414
# copies or substantial portions of the Software.
15-
#
15+
#
1616
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1818
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -106,8 +106,14 @@ def validate_field(self):
106106
raise AttributeError("Primary key fields are already unique")
107107

108108

109-
def get_sql_fields(cls: "SQLMeta") -> dict[str, SQLAttribute]:
110-
return get_attributes(cls) # noqa
109+
def get_sql_fields(cls: "SQLMeta", local=False) -> dict[str, SQLAttribute]:
110+
attribs = get_attributes(cls, local=local)
111+
parents = SQLAttribute.__mro__[1:-1] # remove object and self
112+
attributes = {
113+
k: SQLAttribute.from_field(v) if type(v) in parents else v
114+
for k, v in attribs.items()
115+
}
116+
return attributes
111117

112118

113119
unified_gatherer = make_unified_gatherer(SQLAttribute)
@@ -154,7 +160,14 @@ def __init_subclass__(
154160
**kwargs,
155161
):
156162
slots = "__slots__" in cls.__dict__
157-
builder(cls, gatherer=gatherer, methods=methods, flags={"slotted": slots, "kw_only": True})
163+
164+
builder(
165+
cls,
166+
gatherer=gatherer,
167+
methods=methods,
168+
flags={"slotted": slots, "kw_only": True},
169+
field_getter=get_sql_fields,
170+
)
158171

159172
fields = get_sql_fields(cls)
160173
valid_fields = {}

0 commit comments

Comments
 (0)