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

Mark Extra as deprecated #7299

Merged
merged 6 commits into from Sep 20, 2023

Conversation

disrupted
Copy link
Contributor

@disrupted disrupted commented Aug 30, 2023

Change Summary

Similary to the BaseConfig, Extra is now marked using the @deprecated decorator for IDE support to advise against its usage.

Related issue number

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @dmontagu

@disrupted
Copy link
Contributor Author

please review

@dmontagu
Copy link
Contributor

I just pushed a commit that I think should make the test pass by suppressing the deprecation warning for the instantiation of the Extra class. Let me run this by the other maintainers, but LGTM.

Also, it would be good if you could confirm that with the changes I pushed it still shows the deprecation properly — I use PyCharm which doesn't reflect that decorator properly yet 😕.

Copy link
Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

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

This doesn't work as expected on VSCode because of the reexport on config.py, and the instantiation of _Extra().

# so it is okay to suppress the one coming from the @deprecated decorator here.
warnings.filterwarnings('ignore', category=PydanticDeprecatedSince20)

Extra = _Extra()
Copy link
Member

Choose a reason for hiding this comment

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

Why is it Extra = _Extra() and not Extra = _Extra?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've completely removed the instantiation of Extra now so that it is only re-exported same as BaseConfig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

getattr(Extra, attribute) doesn't seem to work without instantiating it first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reverted the change

Copy link
Contributor

Choose a reason for hiding this comment

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

@Kludex I think we can make that work but then we need to override getattribute on the metaclass. Might help to go over it live so we can confirm it's working with display etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dmontagu @Kludex is there anything else I should do or are you taking this over?

Copy link
Member

Choose a reason for hiding this comment

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

I'm taking over. Thanks @disrupted 🙏

@adriangb adriangb force-pushed the chore/extra-deprecated-decorator branch from d99724c to ea8538b Compare September 20, 2023 08:43
@adriangb adriangb enabled auto-merge (squash) September 20, 2023 08:45
@adriangb adriangb merged commit 38df440 into pydantic:main Sep 20, 2023
47 checks passed
@disrupted disrupted deleted the chore/extra-deprecated-decorator branch September 20, 2023 09:03
@davidhewitt davidhewitt added relnotes-change Used for changes to existing functionality which don't have a better categorization. and removed awaiting author revision labels Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-change Used for changes to existing functionality which don't have a better categorization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants