Skip to content

Commit 88d928c

Browse files
committed
fix builtins
1 parent b1e1354 commit 88d928c

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/scverse_misc/_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def _type_str(cls: type, field: FieldInfo) -> str:
1818
if isinstance(field.annotation, GenericAlias) or not isinstance(field.annotation, type):
1919
return str(field.annotation)
20-
if cls.__module__ == field.annotation.__module__:
20+
if field.annotation.__module__ in {"builtins", cls.__module__}:
2121
return field.annotation.__qualname__
2222
return f"{field.annotation.__module__}.{field.annotation.__qualname__}"
2323

tests/test_settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def test_override_docs(docstring_style: Literal["google", "numpy"], settings: Du
133133
@pytest.mark.parametrize(
134134
("attr", "expected"),
135135
[
136+
pytest.param("string", "str", id="builtin"),
136137
pytest.param("path", "pathlib.Path", id="3rd-party"),
137138
# same module as `S`, so no leading `tests.test_settings.`
138139
pytest.param("t", "test_annotation_format.<locals>.T", id="same-module"),
@@ -145,6 +146,7 @@ def test_annotation_format(attr: str, expected: str) -> None:
145146
class T: ...
146147

147148
class S(Settings, exported_object_name="s"):
149+
string: str
148150
path: Path
149151
t: T
150152

0 commit comments

Comments
 (0)