Skip to content
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

Swap pydantic for dataclasses #128

Merged
merged 55 commits into from
May 17, 2023
Merged

Swap pydantic for dataclasses #128

merged 55 commits into from
May 17, 2023

Conversation

khaeru
Copy link
Owner

@khaeru khaeru commented May 2, 2023

This PR uses dataclasses from the Python standard library for many of the convenience features previously used from pydantic, namely generating __init__() methods automatically for the large number of classes in the SDMX Information Model.

Some effects:

  • The package no longer depends on pydantic; we no longer need to maintain pydantic compatibility code that may break.
  • Validation overhead is reduced where not necessary. In particular, the switch allowed to identify and fix the few instances where internal code usage was not satisfying type expectations.
  • Expansion to SDMX 3.0 (Implement/ensure compat with SDMX 3.0 #87) will be easier.
  • Performance may differ, but since we do not yet have performance tests (Use pytest-profiling and describe performance tests #49) the effect is not clear; anecdotally the test suite seems to take 50% as long to run.

Internal changes:

  • Remove .util.{BaseModel,Field,validate_dictlike,validator}.
  • Remove DictLike.{__get_validators__,_validate_whole}.
  • Organize tests of .model classes in test files that parallel the structure of the module.

PR checklist

  • Address remaining TODOs inline, plus
    • Tidy reuse of __post_init__, __eq__, and __hash__ from parent classes.
    • Remove Key._fast() and usage.
  • Checks all ✅
  • Update documentation
  • Update doc/whatsnew.rst

@khaeru khaeru added the enh Enhancements & new features label May 2, 2023
@khaeru khaeru self-assigned this May 2, 2023
khaeru added a commit that referenced this pull request May 16, 2023
@khaeru khaeru force-pushed the enh/dataclass branch 3 times, most recently from 6302272 to b8e6ab2 Compare May 16, 2023 09:09
@codecov
Copy link

codecov bot commented May 16, 2023

Codecov Report

Merging #128 (92a309e) into main (dae5e79) will decrease coverage by 2.18%.
The diff coverage is 99.36%.

@@            Coverage Diff             @@
##             main     #128      +/-   ##
==========================================
- Coverage   98.10%   95.93%   -2.18%     
==========================================
  Files          72       73       +1     
  Lines        5446     5602     +156     
==========================================
+ Hits         5343     5374      +31     
- Misses        103      228     +125     
Impacted Files Coverage Δ
sdmx/reader/xml.py 97.61% <ø> (-0.45%) ⬇️
sdmx/source/bbk.py 52.94% <ø> (-36.54%) ⬇️
sdmx/tests/reader/test_reader_xml.py 100.00% <ø> (ø)
sdmx/tests/writer/test_writer_xml.py 100.00% <ø> (ø)
sdmx/writer/xml.py 97.57% <83.33%> (-0.77%) ⬇️
sdmx/util.py 98.51% <96.77%> (-1.49%) ⬇️
sdmx/model/v21.py 99.83% <99.23%> (+1.20%) ⬆️
sdmx/client.py 94.05% <100.00%> (-3.79%) ⬇️
sdmx/message.py 100.00% <100.00%> (ø)
sdmx/model/common.py 100.00% <100.00%> (+0.94%) ⬆️
... and 12 more

... and 13 files with indirect coverage changes

@khaeru khaeru merged commit 14f6a01 into main May 17, 2023
@khaeru khaeru deleted the enh/dataclass branch May 17, 2023 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enh Enhancements & new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant