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

fix empty SchemaModel #434

Merged
merged 1 commit into from
Mar 13, 2021
Merged

fix empty SchemaModel #434

merged 1 commit into from
Mar 13, 2021

Conversation

jeffzi
Copy link
Collaborator

@jeffzi jeffzi commented Mar 12, 2021

fixes #433

This PR fixes a bug with empty SchemaModel raising a TypeError.

import pandera as pa

class ASchema(pa.SchemaModel):
    pass

ASchema.to_schema()
# Traceback (most recent call last):
#   File "test.py", line 10, in <module>
#     ASchema.to_schema()
#   File ".../pandera/model.py", line 150, in to_schema
#     cls.__config__ = cls._collect_config()
#   File ".../pandera/model.py", line 331, in _collect_config
#     base_options = _extract_config_options(config)
#   File ".../pandera/model.py", line 97, in _extract_config_options
#     for name, value in vars(config).items()
# TypeError: vars() argument must have __dict__ attribute

The problem comes from __annotations returning its super's annotations (i.e SchemaModel) if the class doesn't have annotations itself. Config is then misinterpreted as a missing field and overwritten.

@jeffzi jeffzi changed the base branch from master to dev March 12, 2021 22:51
@codecov
Copy link

codecov bot commented Mar 12, 2021

Codecov Report

Merging #434 (c05b407) into dev (a2dca76) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #434   +/-   ##
=======================================
  Coverage   99.32%   99.33%           
=======================================
  Files          21       21           
  Lines        2537     2539    +2     
=======================================
+ Hits         2520     2522    +2     
  Misses         17       17           
Impacted Files Coverage Δ
pandera/model.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2dca76...c05b407. Read the comment docs.

Copy link
Collaborator

@cosmicBboy cosmicBboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun bug!

@jeffzi jeffzi merged commit 992dc38 into unionai-oss:dev Mar 13, 2021
cosmicBboy added a commit that referenced this pull request Mar 27, 2021
* fix DataFrameSchema comparison with non-DataFrameSchema (#431)

* increase cache version

* fix DataFrameSchema comparison with non-DataFrameSchema

* fix pylint error

Co-authored-by: cosmicBboy <niels.bantilan@gmail.com>

* add doc about attributes excluded by SchemaModel (#436)

* fix empty SchemaModel (#434)

* fix empty data type not supported for serialization (#435)

* Fix to_yaml serialization dropping global checks (#428)

* increase cache version

* ci: add dataframe checks tests

* bugfix: allow serialization of dataframe checks to_yaml

* ci: add test to ensure serialization of lambda check fails

* bugfix: ensure checks with no parameters generate appropriate schema

* wip: allow looking up registered checks

* fix: compare checks by name rather than by object equality

* ci: black

* ci: lint

* enh: use REGISTERED_CUSTOM_CHECKS for attribute lookup, add dir method

* enh: add to_yaml method to Schema, add unit test

* ci: disable typechecking on _CheckMeta

* ci: isort

* ci: doctests

* ci: improve coverage

* ci: codecov

In these lines, dataframe_checks cannot be None based on the call condition.

* fix unrecognized check dtype during (de)serialization

* fix handle_stat__dtype closures

* enh: move metaclass onto _CheckBase

* ci: add test that ensures to_yaml warns on unregistered checks

* ci: revert adding duplicate test

Co-authored-by: cosmicBboy <niels.bantilan@gmail.com>
Co-authored-by: Jean-Francois Zinque <jzinque@gmail.com>

* remove unnecessary warnings (#441)

since parse_checks handles cases of unregistered checks, the
parts of the io module that raised a user warning were are never
in the execution path and therefore never covered in tests

* bugfix: preserve pandas extension types during validation (#443)

* Update docs (#444)

* update docs theme to Furo light

* add furo

* update styles

* add favicon, update style

Co-authored-by: Jean-Francois Zinque <jzinque@gmail.com>
Co-authored-by: Anton Loukianov <anton.loukianov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mixins with only dataframe_checks cause error in SchemaModel
2 participants