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: handle Optional type recursive models #584

Merged
merged 1 commit into from
Sep 19, 2024
Merged

Conversation

adhtruong
Copy link
Collaborator

Description

  • Handle case based on doc string

Closes

Partially fixes #583

Copy link

sonarcloud bot commented Sep 17, 2024

@guacs guacs merged commit 135d7fe into main Sep 19, 2024
23 checks passed
@guacs guacs deleted the fix-handle-optional-types branch September 19, 2024 10:32
github-merge-queue bot pushed a commit to mozilla/experimenter that referenced this pull request Sep 24, 2024
Bumps [polyfactory](https://github.com/litestar-org/polyfactory) from
2.16.2 to 2.17.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.17.0</h2>
<h1>Sponsors 🌟</h1>
<p>Thanks to these incredible business sponsors:</p>
<p><a href="https://scalar.com/">Scalar</a> (<a
href="https://github.com/scalar"><code>@​scalar</code></a>), <a
href="https://telemetrysports.com/">Telemetry Sports</a> (via <a
href="https://github.com/chris-telemetry"><code>@​chris-telemetry</code></a>),
<a href="https://www.stok.kr/">Stok</a> (<a
href="https://github.com/stok-team"><code>@​stok-team</code></a>)</p>
<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>
<ul>
<li>fix: constrained 0 length lists by <a
href="https://github.com/marcozzxx810"><code>@​marcozzxx810</code></a>
in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/570">litestar-org/polyfactory#570</a></li>
<li>build: update pre-commit dependencies by <a
href="https://github.com/adhtruong"><code>@​adhtruong</code></a> in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/571">litestar-org/polyfactory#571</a></li>
<li>fix: use provider map for any in coverage by <a
href="https://github.com/adhtruong"><code>@​adhtruong</code></a> in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/574">litestar-org/polyfactory#574</a></li>
<li>fix: tuple randomized length by <a
href="https://github.com/adhtruong"><code>@​adhtruong</code></a> in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/573">litestar-org/polyfactory#573</a></li>
<li>feat(<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/579">#579</a>):
enhance register_fixture return type annotation by <a
href="https://github.com/giulioindev"><code>@​giulioindev</code></a> in
<a
href="https://redirect.github.com/litestar-org/polyfactory/pull/581">litestar-org/polyfactory#581</a></li>
<li>docs: swap word with its antonym to match the context by <a
href="https://github.com/UncleGoogle"><code>@​UncleGoogle</code></a> in
<a
href="https://redirect.github.com/litestar-org/polyfactory/pull/575">litestar-org/polyfactory#575</a></li>
<li>fix: Adjust min/max items to valid lengths for Set[Enum] fields by
<a href="https://github.com/adrianeboyd"><code>@​adrianeboyd</code></a>
in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/567">litestar-org/polyfactory#567</a></li>
<li>fix: handle Optional type recursive models by <a
href="https://github.com/adhtruong"><code>@​adhtruong</code></a> in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/584">litestar-org/polyfactory#584</a></li>
<li>fix: handle recursive collections by <a
href="https://github.com/adhtruong"><code>@​adhtruong</code></a> in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/587">litestar-org/polyfactory#587</a></li>
<li>chore(release): bump release version by <a
href="https://github.com/adhtruong"><code>@​adhtruong</code></a> in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/588">litestar-org/polyfactory#588</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/marcozzxx810"><code>@​marcozzxx810</code></a>
made their first contribution in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/570">litestar-org/polyfactory#570</a></li>
<li><a
href="https://github.com/giulioindev"><code>@​giulioindev</code></a>
made their first contribution in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/581">litestar-org/polyfactory#581</a></li>
<li><a
href="https://github.com/UncleGoogle"><code>@​UncleGoogle</code></a>
made their first contribution in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/575">litestar-org/polyfactory#575</a></li>
<li><a
href="https://github.com/adrianeboyd"><code>@​adrianeboyd</code></a>
made their first contribution in <a
href="https://redirect.github.com/litestar-org/polyfactory/pull/567">litestar-org/polyfactory#567</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/litestar-org/polyfactory/compare/v2.16.2...v2.17.0">https://github.com/litestar-org/polyfactory/compare/v2.16.2...v2.17.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>67c5720
&lt;https://github.com/litestar-org/polyfactory/commit/67c57208de5ce993bdb2c7888864ac4e71964511&gt;</code>_
is the last commit in the changelog before unreleased changes.</p>
<p>Bug Fixes

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p>
<ul>
<li>(<code>24701eb
&lt;https://github.com/litestar-org/polyfactory/commit/24701eb593493f7c038709b1327dbf6dd8942e87&gt;</code><em>)
- Constrained 0 length lists (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/570">#570</a>)
by <code>@marcozzxx810
&lt;https://github.com/marcozzxx810&gt;</code></em> in
<code>[#570](litestar-org/polyfactory#570)
&lt;https://github.com/litestar-org/polyfactory/pull/570&gt;</code>_</li>
<li>(<code>6f5b78c
&lt;https://github.com/litestar-org/polyfactory/commit/6f5b78cc5ef3f0fb1037d17d06837af54aac586d&gt;</code><em>)
- Use provider map for any in coverage (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/574">#574</a>)
by <code>@adhtruong &lt;https://github.com/adhtruong&gt;</code></em> in
<code>[#574](litestar-org/polyfactory#574)
&lt;https://github.com/litestar-org/polyfactory/pull/574&gt;</code>_</li>
<li>(<code>4aaf656
&lt;https://github.com/litestar-org/polyfactory/commit/4aaf656baa5b612fa3b63c6047b653b9b785f60d&gt;</code><em>)
- Tuple randomized length (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/573">#573</a>)
by <code>@adhtruong &lt;https://github.com/adhtruong&gt;</code></em> in
<code>[#573](litestar-org/polyfactory#573)
&lt;https://github.com/litestar-org/polyfactory/pull/573&gt;</code>_</li>
<li>(<code>9a83ad6
&lt;https://github.com/litestar-org/polyfactory/commit/9a83ad6354d675b42eb514f9354e845490608ba6&gt;</code><em>)
- Adjust min/max items to valid lengths for Set[Enum] fields (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/567">#567</a>)
by <code>@adrianeboyd &lt;https://github.com/adrianeboyd&gt;</code></em>
in <code>[#567](litestar-org/polyfactory#567)
&lt;https://github.com/litestar-org/polyfactory/pull/567&gt;</code>_</li>
<li>(<code>135d7fe
&lt;https://github.com/litestar-org/polyfactory/commit/135d7fea8d939a1fa8c87838d2b705db8968dccd&gt;</code><em>)
- Handle Optional type recursive models (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/584">#584</a>)
by <code>@adhtruong &lt;https://github.com/adhtruong&gt;</code></em> in
<code>[#584](litestar-org/polyfactory#584)
&lt;https://github.com/litestar-org/polyfactory/pull/584&gt;</code>_</li>
<li>(<code>6440faa
&lt;https://github.com/litestar-org/polyfactory/commit/6440faa24abfc34c2d10e31797224f5aec2d43c0&gt;</code><em>)
- Handle recursive collections (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/587">#587</a>)
by <code>@adhtruong &lt;https://github.com/adhtruong&gt;</code></em> in
<code>[#587](litestar-org/polyfactory#587)
&lt;https://github.com/litestar-org/polyfactory/pull/587&gt;</code>_</li>
</ul>
<p>Documentation

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p>
<ul>
<li>(<code>841831d
&lt;https://github.com/litestar-org/polyfactory/commit/841831d12f59a0825e490e71fdbc32744c433565&gt;</code><em>)
- Swap word with its antonym to match the context (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/575">#575</a>)
by <code>@UncleGoogle &lt;https://github.com/UncleGoogle&gt;</code></em>
in <code>[#575](litestar-org/polyfactory#575)
&lt;https://github.com/litestar-org/polyfactory/pull/575&gt;</code>_</li>
</ul>
<p>Features

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p>
<ul>
<li>(<code>c0c2704
&lt;https://github.com/litestar-org/polyfactory/commit/c0c27049afc9dd60395d5dd087f47ee700e1a6a7&gt;</code><em>)
- Enhance register_fixture return type annotation (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/581">#581</a>)
by <code>@giulioindev &lt;https://github.com/giulioindev&gt;</code></em>
in <code>[#581](litestar-org/polyfactory#581)
&lt;https://github.com/litestar-org/polyfactory/pull/581&gt;</code>_</li>
</ul>
<p>Build

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p>
<ul>
<li>(<code>d75b1d2
&lt;https://github.com/litestar-org/polyfactory/commit/d75b1d2eee3c042b3bf1ea7b8c2b0b6a744df75d&gt;</code><em>)
- Update pre-commit dependencies (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/571">#571</a>)
by <code>@adhtruong &lt;https://github.com/adhtruong&gt;</code></em> in
<code>[#571](litestar-org/polyfactory#571)
&lt;https://github.com/litestar-org/polyfactory/pull/571&gt;</code>_</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/37a9894a52c1188a927c8c9cb5b4485b73d062c3"><code>37a9894</code></a>
chore(release): bump release version (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/588">#588</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/6440faa24abfc34c2d10e31797224f5aec2d43c0"><code>6440faa</code></a>
fix: handle recursive collections (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/587">#587</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/135d7fea8d939a1fa8c87838d2b705db8968dccd"><code>135d7fe</code></a>
fix: handle Optional type recursive models (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/584">#584</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/9a83ad6354d675b42eb514f9354e845490608ba6"><code>9a83ad6</code></a>
fix: Adjust min/max items to valid lengths for Set[Enum] fields (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/567">#567</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/841831d12f59a0825e490e71fdbc32744c433565"><code>841831d</code></a>
docs: swap word with its antonym to match the context (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/575">#575</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/c0c27049afc9dd60395d5dd087f47ee700e1a6a7"><code>c0c2704</code></a>
feat(<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/579">#579</a>):
enhance register_fixture return type annotation (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/581">#581</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/4aaf656baa5b612fa3b63c6047b653b9b785f60d"><code>4aaf656</code></a>
fix: tuple randomized length (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/573">#573</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/6f5b78cc5ef3f0fb1037d17d06837af54aac586d"><code>6f5b78c</code></a>
fix: use provider map for any in coverage (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/574">#574</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/d75b1d2eee3c042b3bf1ea7b8c2b0b6a744df75d"><code>d75b1d2</code></a>
build: update pre-commit dependencies (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/571">#571</a>)</li>
<li><a
href="https://github.com/litestar-org/polyfactory/commit/24701eb593493f7c038709b1327dbf6dd8942e87"><code>24701eb</code></a>
fix: constrained 0 length lists (<a
href="https://redirect.github.com/litestar-org/polyfactory/issues/570">#570</a>)</li>
<li>See full diff in <a
href="https://github.com/litestar-org/polyfactory/compare/v2.16.2...v2.17.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=polyfactory&package-manager=pip&previous-version=2.16.2&new-version=2.17.0)](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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Strange behavior with self-reference model
4 participants