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 bug where - was passing as a valid date. #51

Closed
wants to merge 1 commit into from
Closed

Conversation

sydney-runkle
Copy link
Member

@sydney-runkle sydney-runkle commented Nov 1, 2023

Fix pydantic/pydantic#7872

- is no longer parsing as a valid date.

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Merging #51 (1223c4d) into main (fd0c948) will decrease coverage by 0.32%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
- Coverage   99.10%   98.78%   -0.32%     
==========================================
  Files           6        6              
  Lines         890      903      +13     
==========================================
+ Hits          882      892      +10     
- Misses          8       11       +3     
Files Coverage Δ
src/date.rs 100.00% <100.00%> (ø)
src/numbers.rs 95.45% <100.00%> (-3.28%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

Comment on lines +3 to +13
// Parse bytes as an int with JSON semantics.
pub fn parse_int_with_json_semantics(bytes: &[u8]) -> Option<i64> {
const JSON: u128 = lexical_format::JSON;
let int_options = ParseIntegerOptions::new();
let int_result: Result<i64, lexical_core::Error> = parse_with_options::<i64, JSON>(bytes, &int_options);

match int_result {
Ok(parsed_int) => Some(parsed_int),
Err(_) => None,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

By introducing a new function here it looks like int_parse_bytes and int_parse_str will continue to accept + and - as valid integers. Might it be better to instead fix those functions to reject those inputs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Pushed #51 as an alternative.

@samuelcolvin
Copy link
Member

replaced by #52.

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.

- is parsed as a valid date
3 participants