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: null number field #29

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

fix: null number field #29

wants to merge 5 commits into from

Conversation

laishulu
Copy link

Currently, if number field is None, an exception will be raised.
So there's no way to make the number field nullable.

@@ -192,15 +194,17 @@ def get_internal_type(self):

def to_python(self, value):
# value is either an int or a string of an integer
if isinstance(value, self.number_type):
if isinstance(value, self.number_type) or value is None:
Copy link
Owner

Choose a reason for hiding this comment

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

It is better to add import types to the top, and use if isinstance(value, (self.number_type, types.NoneType)): instead of if isinstance(value, self.number_type) or value is None:.

@svetlyak40wt
Copy link
Owner

Thank you for contribution, but I lack of time to maintain this project. If you wish, I'll grant you access to this repository, so you'll be able to merge you patch yourself. But please, squash commits into one, add a meaningful commit description and write a test for this improvement.

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.

2 participants