question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: extend allow_nan parameter to all number fields

See original GitHub issue

Decimal field has an allow_nan parameter (False by default):

If True, NaN, Infinity and -Infinity are allowed, even though they are illegal according to the JSON specification.

Any objection to extend it to all numbers?

Currently, Int will reject those as they are not integers, but they pass Float which just pawned me.

Should we add the same validation in Float? Move it up to Number?

Even if it is useless for Int, I’d be tempted to extend it to Number.

  • Those are special values with a special meaning so a different error message makes sense.
  • Any Number subclass would inherit it -> less duplication.

This is a breaking change as the default would be False so Float would need to be explicitly passed allow_none=True.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lafrechcommented, Sep 10, 2018

On second thought, from a practical perspective, modifying only Float is easier…

And an Int with allow_nan=True wouldn’t make sense.

Definitely better to do that on a per-field basis.

Shall I shoot a PR for Float?

0reactions
lafrechcommented, Sep 10, 2018

Implementation proposed in #945.

Breaking because default is False and because the signature of the field’s __init__ changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC parameter field values are not reflecting in the ...
Hi, I have added three new fields in the existing table parameters of the RFC by extending the structure.The values are showing up...
Read more >
RFC 7044 - An Extension to the Session Initiation Protocol ...
SIP header field parameters are defined for the History-Info and Contact header ... As per [RFC3261], any implementation not understanding an extension MUST ......
Read more >
RFC 8941: Structured Field Values for HTTP
An extension to a Structured Field can then require that an entire field value be ignored by a recipient that understands the extension...
Read more >
Session Initiation Protocol (SIP) Parameters
Some headers have single-letter compact forms (Section 7.3 of RFC ... field value in a Supported header field in all requests generated by ......
Read more >
2528-type-changing-struct-update-syntax - The Rust RFC Book
Extend struct update syntax (a.k.a. functional record update (FRU)) to support instances ... All fields are visible at the location of the update...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found