-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type annotation in DCSample class #321
Comments
Now, with Py3.12, can check that with
Same error as before: def test_restore(e4cv_renamed, k4cv):
config = DiffractometerConfiguration(e4cv_renamed)
> before = config.export("dict")
hkl/tests/test_configuration.py:37:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
hkl/configuration.py:539: in export
data = getattr(self, f"to_{fmt}")()
hkl/configuration.py:803: in to_dict
return serialize(DCConfiguration, self.model)
hkl/configuration.py:744: in model
obj = deserialize(DCConfiguration, data) # also validates structure
/local/envs/dev-hklpy/lib/python3.12/site-packages/apischema/deserialization/__init__.py:887: in deserialize
return deserialization_method(
...
... many stack entries omitted ...
...
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <apischema.deserialization.DeserializationMethodVisitor object at 0x7f9a3b797d40>
tp = Field(name=None,type=None,default=<dataclasses._MISSING_TYPE object at 0x7f9a9f4489e0>,default_factory=<function DCSample.<lambda> at 0x7f9a65f6a020>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object at 0x7f9a9f4489e0>,_field_type=None)
def unsupported(self, tp: AnyType) -> Result:
> raise Unsupported(tp)
E apischema.visitor.Unsupported: Field(name=None,type=None,default=<dataclasses._MISSING_TYPE object at 0x7f9a9f4489e0>,default_factory=<function DCSample.<lambda> at 0x7f9a65f6a020>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object at 0x7f9a9f4489e0>,_field_type=None)
/local/envs/dev-hklpy/lib/python3.12/site-packages/apischema/visitor.py:151: Unsupported
============================================================== short test summary info ===============================================================
FAILED hkl/tests/test_configuration.py::test_restore - apischema.visitor.Unsupported: Field(name=None,type=None,default=<dataclasses._MISSING_TYPE object at 0x7f9a9f4489e0>,default_factory=<function DCSample.<lambda> at 0x7f9a65f6a020>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object at 0x7f9a9f4489e0>,_field_type=None)
========================================================= 1 failed, 197 deselected in 0.41s ========================================================== |
Neither. Tested the same with Py3.11 & 3.12. This code is in |
prjemian
added a commit
that referenced
this issue
Jan 31, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regarding
hklpy/hkl/configuration.py
Lines 248 to 249 in 32e3043
Is py38 the issue, or is it because DCReflection is not a
dataclass
?I believe the
default_factory
field should be a zero-argument callable, such as...Originally posted by @padraic-shafer in #317 (comment)
The text was updated successfully, but these errors were encountered: