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

Bug: Improve warning message for ambiguous defaults #3372

Closed
3 of 4 tasks
JacobCoffee opened this issue Apr 10, 2024 · 2 comments · Fixed by #3378
Closed
3 of 4 tasks

Bug: Improve warning message for ambiguous defaults #3372

JacobCoffee opened this issue Apr 10, 2024 · 2 comments · Fixed by #3378
Labels
Bug 🐛 This is something that is not working as expected Enhancement This is a new feature or request

Comments

@JacobCoffee
Copy link
Member

JacobCoffee commented Apr 10, 2024

Description

We should enhance the warning messages generated from #3280 in 2.8.

As a user just now upgrading and hitting this, across probably ~40 instances of that warning, this isn't terribly helpful:

.venv/lib/python3.12/site-packages/litestar/typing.py:597: LitestarWarning: Ambiguous default values for annotation 'typing.Annotated[str, ParameterKwarg(examples=None, external_docs=None, content_encoding=None, default='+a', title=None, description='A string expression to filter something.', const=None, gt=None, ge=None, lt=None, le=None, multiple_of=None, min_items=None, max_items=None, min_length=None, max_length=None, pattern=None, lower_case=None, upper_case=None, format=None, enum=None, read_only=None, schema_extra=None, annotation=<_EmptyEnum.EMPTY: 0>, header=None, cookie=None, query=None, required=True)]'. The default value ''+a'' set inside the parameter annotation differs from the parameter default value '<_EmptyEnum.EMPTY: 0>'
  return cls.from_annotation(
.venv/lib/python3.12/site-packages/litestar/typing.py:597: LitestarWarning: Ambiguous default values for annotation 'typing.Annotated[bool, ParameterKwarg(examples=None, external_docs=None, content_encoding=None, default=False, title=None, description='Return something', const=None, gt=None, ge=None, lt=None, le=None, multiple_of=None, min_items=None, max_items=None, min_length=None, max_length=None, pattern=None, lower_case=None, upper_case=None, format=None, enum=None, read_only=None, schema_extra=None, annotation=<_EmptyEnum.EMPTY: 0>, header=None, cookie=None, query=None, required=None)]'. The default value 'False' set inside the parameter annotation differs from the parameter default value '<_EmptyEnum.EMPTY: 0>'
  return cls.from_annotation(

URL to code causing the issue

No response

MCVE

No response

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

2.8

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@JacobCoffee JacobCoffee added Bug 🐛 This is something that is not working as expected Enhancement This is a new feature or request labels Apr 10, 2024
@peterschutt peterschutt changed the title Bug / Enhancement: Bug / Enhancement: Improve warning message for ambiguous defaults Apr 11, 2024
@peterschutt peterschutt changed the title Bug / Enhancement: Improve warning message for ambiguous defaults Bug: Improve warning message for ambiguous defaults Apr 11, 2024
peterschutt added a commit that referenced this issue Apr 12, 2024
We now only issue a single warning for the case where a default value is supplied via `Parameter()` and not via a regular signature default.

Closes #3372
peterschutt added a commit that referenced this issue Apr 12, 2024
We now only issue a single warning for the case where a default value is supplied via `Parameter()` and not via a regular signature default.

Closes #3372
peterschutt added a commit that referenced this issue Apr 12, 2024
We now only issue a single warning for the case where a default value is supplied via `Parameter()` and not via a regular signature default.

Closes #3372
peterschutt added a commit that referenced this issue Apr 12, 2024
We now only issue a single warning for the case where a default value is supplied via `Parameter()` and not via a regular signature default.

Closes #3372
Copy link

This issue has been closed in #3378. The change will be included in the upcoming patch release.

peterschutt added a commit that referenced this issue May 1, 2024
We now only issue a single warning for the case where a default value is supplied via `Parameter()` and not via a regular signature default.

Closes #3372

(cherry picked from commit 7b93d97)
peterschutt added a commit that referenced this issue May 2, 2024
We now only issue a single warning for the case where a default value is supplied via `Parameter()` and not via a regular signature default.

Closes #3372

(cherry picked from commit 7b93d97)
Copy link

github-actions bot commented Jun 2, 2024

A fix for this issue has been released in v2.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 This is something that is not working as expected Enhancement This is a new feature or request
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

1 participant