-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat: add_providers to easily add new type provider #659
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Let's let a few other take a look before merging though.
Friendly reminder on this pull request. Please provide any updates or additional information if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change and feature looks good!
Things to update
- Small copy and formatting update
- Can docs be updated with an example to allow discoverability? Maybe under
docs/usage/configuration
?
Merged your changes in and added a docs example! |
c804f9c
to
b23a2dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating and work on this!
Without modifying the factory class. This enables 3rd party custom types to easily add providers.
Co-authored-by: Andrew Truong <[email protected]>
Co-authored-by: Andrew Truong <[email protected]>
b23a2dd
to
730db99
Compare
Documentation preview will be available shortly at https://litestar-org.github.io/polyfactory-docs-preview/659 |
@all-contributors add @iloveitaly for code doc |
I've put up a pull request to add @iloveitaly! 🎉 |
Hi, I'm looking forward that cool feature in the next version. Any plans when? |
@iloveitaly already contributed before to code, doc |
Bumps [polyfactory](https://github.com/litestar-org/polyfactory) from 2.19.0 to 2.20.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/litestar-org/polyfactory/releases">polyfactory's releases</a>.</em></p> <blockquote> <h2>v2.20.0</h2> <h1>Sponsors 🌟</h1> <p>A huge 'Thank you!' to all other sponsors across <a href="https://polar.sh/litestar-org">Polar.sh</a>, <a href="https://opencollective.com/litestar">OpenCollective</a> and <a href="https://github.com/sponsors/litestar-org/">GitHub Sponsors</a>!</p> <h2>What's Changed</h2> <p>### New Features 🚀</p> <ul> <li>feat: described an ability to use async data in factory fields; refactored factories/base and some tests by <a href="https://github.com/nisemenov"><code>@nisemenov</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/641">litestar-org/polyfactory#641</a></li> <li>feat: simplify pytest plugin by <a href="https://github.com/adhtruong"><code>@adhtruong</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/652">litestar-org/polyfactory#652</a></li> <li>feat: add_providers to easily add new type provider by <a href="https://github.com/iloveitaly"><code>@iloveitaly</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/659">litestar-org/polyfactory#659</a></li> <li>feat: improve random range by <a href="https://github.com/adhtruong"><code>@adhtruong</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/653">litestar-org/polyfactory#653</a></li> <li>feat: improve create factory typing by <a href="https://github.com/adhtruong"><code>@adhtruong</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/657">litestar-org/polyfactory#657</a></li> </ul> <p>### Fixes 🔧</p> <ul> <li>fix: allow non-hashable type args by <a href="https://github.com/adhtruong"><code>@adhtruong</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/643">litestar-org/polyfactory#643</a></li> <li>fix(pyproject.toml): dont allow faker version less then 5.0.0 by <a href="https://github.com/T0nd0Tara"><code>@T0nd0Tara</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/646">litestar-org/polyfactory#646</a></li> <li>build: update dependencies and ignores by <a href="https://github.com/adhtruong"><code>@adhtruong</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/648">litestar-org/polyfactory#648</a></li> <li>fix(<a href="https://redirect.github.com/litestar-org/polyfactory/issues/634">#634</a>): added a generate function to support SQL Numeric field by <a href="https://github.com/nisemenov"><code>@nisemenov</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/636">litestar-org/polyfactory#636</a></li> <li>fix: ignore dataclass types in pydantic field parsing by <a href="https://github.com/adhtruong"><code>@adhtruong</code></a> in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/660">litestar-org/polyfactory#660</a></li> </ul> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/T0nd0Tara"><code>@T0nd0Tara</code></a> made their first contribution in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/646">litestar-org/polyfactory#646</a></li> <li><a href="https://github.com/iloveitaly"><code>@iloveitaly</code></a> made their first contribution in <a href="https://redirect.github.com/litestar-org/polyfactory/pull/659">litestar-org/polyfactory#659</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/litestar-org/polyfactory/compare/v2.19.0...v2.20.0">https://github.com/litestar-org/polyfactory/compare/v2.19.0...v2.20.0</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/litestar-org/polyfactory/blob/main/docs/changelog.rst">polyfactory's changelog</a>.</em></p> <blockquote> <h1>========= Changelog</h1> <p>All commits to this project will be documented in this file.</p> <h2>[unreleased]</h2> <p><code>de78949 <https://github.com/litestar-org/polyfactory/commit/de789499f8b16b49c9fae5954cfba8ad868fff58></code>_ is the last commit in the changelog before unreleased changes.</p> <p>Bug Fixes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p> <ul> <li>(<code>64fa119 <https://github.com/litestar-org/polyfactory/commit/64fa119f7caa2d8c616e3dc2c50ae9c232616351></code><em>) - Allow non-hashable type args (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/643">#643</a>) by <code>@adhtruong <https://github.com/adhtruong></code></em> in <code>[#643](litestar-org/polyfactory#643) <https://github.com/litestar-org/polyfactory/pull/643></code>_</li> <li>(<code>703aa2e <https://github.com/litestar-org/polyfactory/commit/703aa2ef2d2b2489b0c817f6f0d9e75714e1069b></code><em>) - Dont allow faker version less then 5.0.0 (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/646">#646</a>) by <code>@T0nd0Tara <https://github.com/T0nd0Tara></code></em> in <code>[#646](litestar-org/polyfactory#646) <https://github.com/litestar-org/polyfactory/pull/646></code>_</li> <li>(<code>e4a27ca <https://github.com/litestar-org/polyfactory/commit/e4a27cab597f60f142210eaca66a3f97188810f0></code><em>) - Added a generate function to support SQL Numeric field (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/636">#636</a>) by <code>@nisemenov <https://github.com/nisemenov></code></em> in <code>[#636](litestar-org/polyfactory#636) <https://github.com/litestar-org/polyfactory/pull/636></code>_</li> <li>(<code>da6ad4d <https://github.com/litestar-org/polyfactory/commit/da6ad4d213aec4447e9b3b257ab5fed392f445ae></code><em>) - Ignore dataclass types in pydantic field parsing (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/660">#660</a>) by <code>@adhtruong <https://github.com/adhtruong></code></em> in <code>[#660](litestar-org/polyfactory#660) <https://github.com/litestar-org/polyfactory/pull/660></code>_</li> </ul> <p>Documentation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p> <ul> <li>(<code>3c1e68f <https://github.com/litestar-org/polyfactory/commit/3c1e68ffbfa59d0ed9b9cc41d9b9a17654b841e4></code><em>) - Add nisemenov as a contributor for code, and doc (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/633">#633</a>) by <code>@allcontributors[bot] <https://github.com/allcontributors[bot]></code></em> in <code>[#633](litestar-org/polyfactory#633) <https://github.com/litestar-org/polyfactory/pull/633></code>_</li> <li>(<code>beab66c <https://github.com/litestar-org/polyfactory/commit/beab66cf39a8bf67e3a1ac41cde30ee27ee08be1></code><em>) - Add iloveitaly as a contributor for code, and doc (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/662">#662</a>) by <code>@allcontributors[bot] <https://github.com/allcontributors[bot]></code></em> in <code>[#662](litestar-org/polyfactory#662) <https://github.com/litestar-org/polyfactory/pull/662></code>_</li> </ul> <p>Features ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p> <ul> <li>(<code>8c1fe02 <https://github.com/litestar-org/polyfactory/commit/8c1fe0293a525fdd20aaadbbf09f8a31dffcdaf8></code><em>) - Described an ability to use async data in factory fields; refactored factories/base and some tests (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/641">#641</a>) by <code>@nisemenov <https://github.com/nisemenov></code></em> in <code>[#641](litestar-org/polyfactory#641) <https://github.com/litestar-org/polyfactory/pull/641></code>_</li> <li>(<code>ba7cd3f <https://github.com/litestar-org/polyfactory/commit/ba7cd3f382140523d61b35c9ed572c74d8c1ef9f></code><em>) - Simplify pytest plugin (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/652">#652</a>) by <code>@adhtruong <https://github.com/adhtruong></code></em> in <code>[#652](litestar-org/polyfactory#652) <https://github.com/litestar-org/polyfactory/pull/652></code>_</li> <li>(<code>b98ae5d <https://github.com/litestar-org/polyfactory/commit/b98ae5d1c50d24748903e65a8d3b1674f1043f2c></code><em>) - Improve create factory typing (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/657">#657</a>) by <code>@adhtruong <https://github.com/adhtruong></code></em> in <code>[#657](litestar-org/polyfactory#657) <https://github.com/litestar-org/polyfactory/pull/657></code>_</li> <li>(<code>33c72e7 <https://github.com/litestar-org/polyfactory/commit/33c72e7bcd1388756a2235e4d75b74fe0de16d27></code><em>) - Add_providers to easily add new type provider (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/659">#659</a>) by <code>@iloveitaly <https://github.com/iloveitaly></code></em> in <code>[#659](litestar-org/polyfactory#659) <https://github.com/litestar-org/polyfactory/pull/659></code>_</li> <li>(<code>0b5df15 <https://github.com/litestar-org/polyfactory/commit/0b5df15bd324a7ac2079947dd600e899f2b10798></code><em>) - Improve random range (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/653">#653</a>) by <code>@adhtruong <https://github.com/adhtruong></code></em> in <code>[#653](litestar-org/polyfactory#653) <https://github.com/litestar-org/polyfactory/pull/653></code>_</li> </ul> <p>Miscellaneous Tasks ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p> <ul> <li>(<code>f5cb818 <https://github.com/litestar-org/polyfactory/commit/f5cb818314bf4887f2caab2c3961d1dd886b68cc></code><em>) - Bump dawidd6/action-download-artifact from 7 to 9 (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/651">#651</a>) by <code>@dependabot[bot] <https://github.com/dependabot[bot]></code></em> in <code>[#651](litestar-org/polyfactory#651) <https://github.com/litestar-org/polyfactory/pull/651></code>_</li> <li>(<code>1c56f09 <https://github.com/litestar-org/polyfactory/commit/1c56f09692214cefcfcd3bc29ba9b74fc18a940f></code><em>) - Bump codecov/codecov-action from 4 to 5 (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/620">#620</a>) by <code>@dependabot[bot] <https://github.com/dependabot[bot]></code></em> in <code>[#620](litestar-org/polyfactory#620) <https://github.com/litestar-org/polyfactory/pull/620></code>_</li> <li>(<code>516dd6d <https://github.com/litestar-org/polyfactory/commit/516dd6d280ee35afda068c7ecaa0d672daf971d1></code><em>) - Improve test imports (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/661">#661</a>) by <code>@adhtruong <https://github.com/adhtruong></code></em> in <code>[#661](litestar-org/polyfactory#661) <https://github.com/litestar-org/polyfactory/pull/661></code>_</li> </ul> <p>Build ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p> <ul> <li>(<code>34182d4 <https://github.com/litestar-org/polyfactory/commit/34182d439d5d5f1f1964a961c028859e3b404851></code><em>) - Update dependencies and ignores (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/648">#648</a>) by <code>@adhtruong <https://github.com/adhtruong></code></em> in <code>[#648](litestar-org/polyfactory#648) <https://github.com/litestar-org/polyfactory/pull/648></code>_</li> <li>(<code>396b555 <https://github.com/litestar-org/polyfactory/commit/396b5559ec2a2bbf7818dd15a75b556c18849183></code><em>) - Update pyright (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/665">#665</a>) by <code>@adhtruong <https://github.com/adhtruong></code></em> in <code>[#665](litestar-org/polyfactory#665) <https://github.com/litestar-org/polyfactory/pull/665></code>_</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/litestar-org/polyfactory/commit/0facd26ec2e8915e1769e90ffb55ccccd60aadc5"><code>0facd26</code></a> chore: prep 2.20.0 release (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/669">#669</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/396b5559ec2a2bbf7818dd15a75b556c18849183"><code>396b555</code></a> build: update pyright (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/665">#665</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/beab66cf39a8bf67e3a1ac41cde30ee27ee08be1"><code>beab66c</code></a> docs: add iloveitaly as a contributor for code, and doc (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/662">#662</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/0b5df15bd324a7ac2079947dd600e899f2b10798"><code>0b5df15</code></a> feat: improve random range (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/653">#653</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/33c72e7bcd1388756a2235e4d75b74fe0de16d27"><code>33c72e7</code></a> feat: add_providers to easily add new type provider (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/659">#659</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/516dd6d280ee35afda068c7ecaa0d672daf971d1"><code>516dd6d</code></a> chore: improve test imports (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/661">#661</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/b98ae5d1c50d24748903e65a8d3b1674f1043f2c"><code>b98ae5d</code></a> feat: improve create factory typing (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/657">#657</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/da6ad4d213aec4447e9b3b257ab5fed392f445ae"><code>da6ad4d</code></a> fix: ignore dataclass types in pydantic field parsing (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/660">#660</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/ba7cd3f382140523d61b35c9ed572c74d8c1ef9f"><code>ba7cd3f</code></a> feat: simplify pytest plugin (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/652">#652</a>)</li> <li><a href="https://github.com/litestar-org/polyfactory/commit/1c56f09692214cefcfcd3bc29ba9b74fc18a940f"><code>1c56f09</code></a> chore(deps): bump codecov/codecov-action from 4 to 5 (<a href="https://redirect.github.com/litestar-org/polyfactory/issues/620">#620</a>)</li> <li>Additional commits viewable in <a href="https://github.com/litestar-org/polyfactory/compare/v2.19.0...v2.20.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Description
Without modifying the factory class. This enables 3rd party custom types to easily add providers.