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 imports indirectly from pydantic typing #4358

Merged
merged 8 commits into from Aug 11, 2022

Conversation

aminalaee
Copy link
Contributor

@aminalaee aminalaee commented Aug 9, 2022

Change Summary

Some imports indirectly get ForwardRef and other types from .typing instead of typing module. I came across this when I was working on something else.

Closes #4182

Related issue number

None

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

pydantic/fields.py Outdated Show resolved Hide resolved
@aminalaee
Copy link
Contributor Author

This will also close #4182 to keep consistency in pydantic.typing.__all__

@samuelcolvin
Copy link
Member

This will also close #4182 to keep consistency in pydantic.typing.__all__

Thanks, if this is closing issues, please put them in the PR body so they get auto-closed.

Please update.

@aminalaee
Copy link
Contributor Author

please review

@hramezani
Copy link
Member

Thanks @aminalaee for the patch 👍

There are some other ForwardRef that can be replaced:

  • from pydantic.typing import ForwardRef
  • There are some tests that have from pydantic.typing import ForwardRef that can be replaced by from typing import ForwardRef:
    def test_basic_forward_ref(create_module):
    @create_module
    def module():
    from typing import Optional
    from pydantic import BaseModel
    from pydantic.typing import ForwardRef

@hramezani
Copy link
Member

hramezani commented Aug 9, 2022

please update

@aminalaee
Copy link
Contributor Author

Thank you for the review @hramezani . I'd only checked the top imports, this should be ok now. please review.

Copy link
Member

@hramezani hramezani left a comment

Choose a reason for hiding this comment

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

Thanks @aminalaee for the update 👍

@samuelcolvin
Copy link
Member

Hi @aminalaee please update to add a change file.

Otherwise LGTM.

@aminalaee
Copy link
Contributor Author

Sorry I'd forgotten to add that. please review again.

@samuelcolvin
Copy link
Member

Thanks so much.

@aminalaee aminalaee deleted the fix-imports-from-typing branch August 11, 2022 12:22
auphofBSF pushed a commit to auphofBSF/sqlmodel that referenced this pull request Oct 18, 2022
current pydantic 1.10.2
see pydantic/pydantic#4358
Fix imports indirectly from pydantic typing #4358
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"MappingIntStrAny" not declared in __all__
4 participants