Skip to content

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.

4 participants