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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve ForwardRef on Field.outer_type_ #4249

Merged

Conversation

JacobHayes
Copy link
Contributor

@JacobHayes JacobHayes commented Jul 18, 2022

Change Summary

When resolving ForwardRefs, the Field.outer_type_ is not resolved, only Field.type_. This PR updates update_field_forward_refs to resolve both attributes, while still only calling Field.prepare once.

Field.outer_type_ can be a nested object (eg: List[str], etc), but I only check if the entire annotation is a ForwardRef for simplicity. This should cover most cases, namely:

  • all from __future__ import annoations annotations
  • manually stringized annotations as long as the whole annotation is stringized (eg: "List[RecursiveType]" will be resolved, List["RecursiveType"] will not)

I think I've seen other instances where ForwardRefs inside nested types aren't full resolved, so 馃 this is fine for now.

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

@JacobHayes
Copy link
Contributor Author

I think this is ready, please review 馃檹

@samuelcolvin
Copy link
Member

thanks so much.

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.

None yet

4 participants