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

better error message for TypeError on datetime parsing #766

Merged
merged 3 commits into from Aug 21, 2019

Conversation

@samuelcolvin
Copy link
Owner

samuelcolvin commented Aug 18, 2019

Change Summary

While working on #763 I discovered that we had no tests and ugly errors if anything other than a native datetime/date/time/timedelta, string, int or float was passed to those parsers.

Changes:

  • fix the above - more descriptive error message
  • add support for bytes by decoding them before regex matching
  • change invalid values to be value_errors not type_errors - more correct.

Github doesn't do a very good job of showing it, but this change is mainly just an indentation change plus adding if isinstance(value, bytes): value = value.decode().

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.rst file added describing change
    (see changes/README.md for details)
@codecov

This comment has been minimized.

Copy link

codecov bot commented Aug 21, 2019

Codecov Report

Merging #766 into master will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff          @@
##           master   #766   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          15     15           
  Lines        2734   2747   +13     
  Branches      541    546    +5     
=====================================
+ Hits         2734   2747   +13
Impacted Files Coverage Δ
pydantic/errors.py 100% <100%> (ø) ⬆️
pydantic/datetime_parse.py 100% <100%> (ø) ⬆️

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 0e8cfba...74c597a. Read the comment docs.

@samuelcolvin samuelcolvin merged commit 9dee83a into master Aug 21, 2019
12 checks passed
12 checks passed
Header rules No header rules processed
Details
Pages changed All files already uploaded
Details
Redirect rules No redirect rules processed
Details
Mixed content No mixed content detected
Details
codecov/project 100% (+0%) compared to 0e8cfba
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details
pyup.io/safety-ci No dependencies with known security vulnerabilities.
Details
samuelcolvin.pydantic Build #20190821.18 succeeded
Details
samuelcolvin.pydantic (Job Python36) Job Python36 succeeded
Details
samuelcolvin.pydantic (Job Python37) Job Python37 succeeded
Details
@samuelcolvin samuelcolvin deleted the datetime-type-errors branch Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.