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

feat!: no implicit default for optional params #3361

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

peterschutt
Copy link
Contributor

@peterschutt peterschutt commented Apr 9, 2024

Description

  • This PR changes behavior of parameters that are typed in a union with None. Prior behavior was to implicitly default their value to None if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.

Closes

Closes #2518

@peterschutt peterschutt requested review from a team as code owners April 9, 2024 22:28
@peterschutt peterschutt force-pushed the v3-no-implicit-optional-defaults-new-docs branch 2 times, most recently from 7197ec2 to 361c9d2 Compare April 9, 2024 23:25
Base automatically changed from new-docs to v3.0 April 10, 2024 06:59
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
@peterschutt peterschutt force-pushed the v3-no-implicit-optional-defaults-new-docs branch from 361c9d2 to 7f80ce5 Compare April 10, 2024 07:24
@github-actions github-actions bot added area/docs This PR involves changes to the documentation area/private-api This PR involves changes to the privatized API size: small type/feat Breaking 🔨 area/kwargs pr/internal labels Apr 10, 2024
Copy link

sonarcloud bot commented Apr 10, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3361

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.28%. Comparing base (890bf45) to head (7f80ce5).

❗ Current head 7f80ce5 differs from pull request most recent head 3366836. Consider uploading reports for the commit 3366836 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             v3.0    #3361      +/-   ##
==========================================
+ Coverage   98.24%   98.28%   +0.03%     
==========================================
  Files         321      323       +2     
  Lines       14687    14772      +85     
  Branches     2334     2345      +11     
==========================================
+ Hits        14429    14518      +89     
  Misses        116      116              
+ Partials      142      138       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@peterschutt peterschutt merged commit 9e08c8f into v3.0 Apr 10, 2024
16 of 20 checks passed
@peterschutt peterschutt deleted the v3-no-implicit-optional-defaults-new-docs branch April 10, 2024 20:35
provinzkraut pushed a commit that referenced this pull request Apr 13, 2024
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
provinzkraut pushed a commit that referenced this pull request Apr 20, 2024
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
provinzkraut pushed a commit that referenced this pull request Apr 21, 2024
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
provinzkraut pushed a commit that referenced this pull request Apr 27, 2024
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
provinzkraut pushed a commit that referenced this pull request Apr 27, 2024
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
provinzkraut pushed a commit that referenced this pull request Apr 28, 2024
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
provinzkraut pushed a commit that referenced this pull request May 25, 2024
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
provinzkraut pushed a commit that referenced this pull request May 26, 2024
This PR changes behavior of parameters that are typed in a union with `None`. Prior behavior was to implicitly default their value to `None` if a value wasn't provided making an apparently non-optional parameter (i.e., no declared default) actually optional. Surprising behavior at best, dangerous at worst.

New behavior is to throw a client error when a parameter without a default is not provided.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs This PR involves changes to the documentation area/kwargs area/private-api This PR involves changes to the privatized API Breaking 🔨 pr/internal size: small type/feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants