litestar-org / polyfactory

Simple and powerful factories for mock data generation
https://polyfactory.litestar.dev/
MIT License
1k stars 78 forks source link

Bug: Support for Python 3.12 type keyword #455

Closed sherbang closed 8 months ago

sherbang commented 9 months ago

Description

When upgrading from Python 3.11 syntax to 3.12, my TypeAliases are now type lines.

Ex:

LiteralAlias: TypeAlias = Literal['a','b','c']

becomes

type LiteralAlias = Literal['a','b','c']

With this change Polyfactory no longer recognizes the type:

E       polyfactory.exceptions.ParameterException: Unsupported type: LiteralAlias
E       
E       Either extend the providers map or add a factory function for this type.

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

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

Screenshots

"In the format of: ![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Release Version

2.12.0

Platform


[!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

guacs commented 9 months ago

@sherbang thanks for pointing this out! Yeah, we'll have to make any relevant changes that may be needed in order to properly support 3.12.