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

After upgrade to 4.0.1+ dict validation crushed ValueError: not enough values to unpack #373

Closed
2 tasks done
mrquokka opened this issue Jul 31, 2023 · 0 comments
Closed
2 tasks done
Labels

Comments

@mrquokka
Copy link

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Typeguard version

4.0.1+

Python version

3.10, 3.11

What happened?

value = {'RootClass__name': '1А', 'type': 'NominalCurrent'}, origin_type = <class 'dict'>
args = (<class 'str'>,), memo = <typeguard.TypeCheckMemo object at 0x7f22f1b47dc0>

    def check_mapping(
        value: Any,
        origin_type: Any,
        args: tuple[Any, ...],
        memo: TypeCheckMemo,
    ) -> None:
        if origin_type is Dict or origin_type is dict:
            if not isinstance(value, dict):
                raise TypeCheckError("is not a dict")
        if origin_type is MutableMapping or origin_type is collections.abc.MutableMapping:
            if not isinstance(value, collections.abc.MutableMapping):
                raise TypeCheckError("is not a mutable mapping")
        elif not isinstance(value, collections.abc.Mapping):
            raise TypeCheckError("is not a mapping")
    
        if args:
>           key_type, value_type = args
E           ValueError: not enough values to unpack (expected 2, got 1)

/work/envs/beta/lib/python3.10/site-packages/typeguard/_checkers.py:220: ValueError
====================================== short test summary info ======================================
FAILED pytest_5_8_0_dev8.py::test_upgrade - ValueError: not enough values to unpack (expected 2, got 1)

on 4.0.0 works stable

How can we reproduce the bug?

import typing
from typeguard import typechecked


@typechecked
def upgrade(
  cimxml: dict[str, dict[str, typing.Any]],
  files_by_container: dict[
    str, dict[str, str | bytes | dict[str, typing.Any] | list[typing.Any]]
  ],
) -> None:
  ...


upgrade(
  {"123": {"RootClass__name": "1А", "type": "NominalCurrent"}},
  {"folder_1": {"file_1": "123"}},
)

@mrquokka mrquokka added the bug label Jul 31, 2023
zanieb pushed a commit to astral-sh/ruff-lsp that referenced this issue Aug 18, 2023
Bumps [typeguard](https://github.com/agronholm/typeguard) from 4.1.1 to
4.1.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/agronholm/typeguard/blob/master/docs/versionhistory.rst">typeguard's
changelog</a>.</em></p>
<blockquote>
<h1>Version history</h1>
<p>This library adheres to <code>Semantic Versioning 2.0
&lt;https://semver.org/#semantic-versioning-200&gt;</code>_.</p>
<p><strong>UNRELEASED</strong></p>
<ul>
<li>Dropped Python 3.7 support</li>
</ul>
<p><strong>4.1.2</strong> (2023-08-18)</p>
<ul>
<li>Fixed <code>Any</code> being removed from a subscript that still
contains other elements
(<code>[#373](agronholm/typeguard#373)
&lt;https://github.com/agronholm/typeguard/issues/373&gt;</code>_</li>
</ul>
<p><strong>4.1.1</strong> (2023-08-16)</p>
<ul>
<li>Fixed <code>suppress_type_checks()</code> causing annotated variable
assignments to always
assign <code>None</code>
(<code>[#380](agronholm/typeguard#380)
&lt;https://github.com/agronholm/typeguard/issues/380&gt;</code>_)</li>
</ul>
<p><strong>4.1.0</strong> (2023-07-30)</p>
<ul>
<li>Added support for passing a tuple as <code>expected_type</code> to
<code>check_type()</code>, making it
more of a drop-in replacement for <code>isinstance()</code>
(<code>[#371](agronholm/typeguard#371)
&lt;https://github.com/agronholm/typeguard/issues/371&gt;</code>_</li>
<li>Fixed regression where <code>Literal</code> inside a
<code>Union</code> had quotes stripped from its
contents, thus typically causing <code>NameError</code> to be raised
when run
(<code>[#372](agronholm/typeguard#372)
&lt;https://github.com/agronholm/typeguard/issues/372&gt;</code>_)</li>
</ul>
<p><strong>4.0.1</strong> (2023-07-27)</p>
<ul>
<li>Fixed handling of <code>typing_extensions.Literal</code> on Python
3.8 and 3.9 when
<code>typing_extensions&gt;=4.6.0</code> is installed
(<code>[#363](agronholm/typeguard#363)
&lt;https://github.com/agronholm/typeguard/issues/363&gt;</code>_; PR by
Alex Waygood)</li>
<li>Fixed <code>NameError</code> when generated type checking code
references an imported name from
a method
(<code>[#362](agronholm/typeguard#362)
&lt;https://github.com/agronholm/typeguard/issues/362&gt;</code>_)</li>
<li>Fixed docstrings disappearing from instrumented functions
(<code>[#359](agronholm/typeguard#359)
&lt;https://github.com/agronholm/typeguard/issues/359&gt;</code>_)</li>
<li>Fixed <code>@TypeChecked</code> failing to instrument functions when
there are more than one
function within the same scope
(<code>[#355](agronholm/typeguard#355)
&lt;https://github.com/agronholm/typeguard/issues/355&gt;</code>_)</li>
<li>Fixed <code>frozenset</code> not being checked
(<code>[#367](agronholm/typeguard#367)
&lt;https://github.com/agronholm/typeguard/issues/367&gt;</code>_)</li>
</ul>
<p><strong>4.0.0</strong> (2023-05-12)</p>
<ul>
<li>No changes</li>
</ul>
<p><strong>4.0.0rc6</strong> (2023-05-07)</p>
<ul>
<li>Fixed <code>@TypeChecked</code> optimization causing compilation of
instrumented code to fail</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/agronholm/typeguard/commit/d7a705e329529456898265d94adbdafed0c4c22c"><code>d7a705e</code></a>
Added release date</li>
<li><a
href="https://github.com/agronholm/typeguard/commit/d07fbb4fd49e716c4db12a6fca3dcfa8a58fd6d2"><code>d07fbb4</code></a>
Fixed Any being removed from a subscript that still contains other
elements</li>
<li>See full diff in <a
href="https://github.com/agronholm/typeguard/compare/4.1.1...4.1.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=typeguard&package-manager=pip&previous-version=4.1.1&new-version=4.1.2)](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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
azurelotus0926 added a commit to azurelotus0926/ruff-lsp that referenced this issue Jun 27, 2024
Bumps [typeguard](https://github.com/agronholm/typeguard) from 4.1.1 to
4.1.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/agronholm/typeguard/blob/master/docs/versionhistory.rst">typeguard's
changelog</a>.</em></p>
<blockquote>
<h1>Version history</h1>
<p>This library adheres to <code>Semantic Versioning 2.0
&lt;https://semver.org/#semantic-versioning-200&gt;</code>_.</p>
<p><strong>UNRELEASED</strong></p>
<ul>
<li>Dropped Python 3.7 support</li>
</ul>
<p><strong>4.1.2</strong> (2023-08-18)</p>
<ul>
<li>Fixed <code>Any</code> being removed from a subscript that still
contains other elements
(<code>[#373](agronholm/typeguard#373)
&lt;https://github.com/agronholm/typeguard/issues/373&gt;</code>_</li>
</ul>
<p><strong>4.1.1</strong> (2023-08-16)</p>
<ul>
<li>Fixed <code>suppress_type_checks()</code> causing annotated variable
assignments to always
assign <code>None</code>
(<code>[#380](agronholm/typeguard#380)
&lt;https://github.com/agronholm/typeguard/issues/380&gt;</code>_)</li>
</ul>
<p><strong>4.1.0</strong> (2023-07-30)</p>
<ul>
<li>Added support for passing a tuple as <code>expected_type</code> to
<code>check_type()</code>, making it
more of a drop-in replacement for <code>isinstance()</code>
(<code>[#371](agronholm/typeguard#371)
&lt;https://github.com/agronholm/typeguard/issues/371&gt;</code>_</li>
<li>Fixed regression where <code>Literal</code> inside a
<code>Union</code> had quotes stripped from its
contents, thus typically causing <code>NameError</code> to be raised
when run
(<code>[#372](agronholm/typeguard#372)
&lt;https://github.com/agronholm/typeguard/issues/372&gt;</code>_)</li>
</ul>
<p><strong>4.0.1</strong> (2023-07-27)</p>
<ul>
<li>Fixed handling of <code>typing_extensions.Literal</code> on Python
3.8 and 3.9 when
<code>typing_extensions&gt;=4.6.0</code> is installed
(<code>[#363](agronholm/typeguard#363)
&lt;https://github.com/agronholm/typeguard/issues/363&gt;</code>_; PR by
Alex Waygood)</li>
<li>Fixed <code>NameError</code> when generated type checking code
references an imported name from
a method
(<code>[#362](agronholm/typeguard#362)
&lt;https://github.com/agronholm/typeguard/issues/362&gt;</code>_)</li>
<li>Fixed docstrings disappearing from instrumented functions
(<code>[#359](agronholm/typeguard#359)
&lt;https://github.com/agronholm/typeguard/issues/359&gt;</code>_)</li>
<li>Fixed <code>@TypeChecked</code> failing to instrument functions when
there are more than one
function within the same scope
(<code>[#355](agronholm/typeguard#355)
&lt;https://github.com/agronholm/typeguard/issues/355&gt;</code>_)</li>
<li>Fixed <code>frozenset</code> not being checked
(<code>[#367](agronholm/typeguard#367)
&lt;https://github.com/agronholm/typeguard/issues/367&gt;</code>_)</li>
</ul>
<p><strong>4.0.0</strong> (2023-05-12)</p>
<ul>
<li>No changes</li>
</ul>
<p><strong>4.0.0rc6</strong> (2023-05-07)</p>
<ul>
<li>Fixed <code>@TypeChecked</code> optimization causing compilation of
instrumented code to fail</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/agronholm/typeguard/commit/d7a705e329529456898265d94adbdafed0c4c22c"><code>d7a705e</code></a>
Added release date</li>
<li><a
href="https://github.com/agronholm/typeguard/commit/d07fbb4fd49e716c4db12a6fca3dcfa8a58fd6d2"><code>d07fbb4</code></a>
Fixed Any being removed from a subscript that still contains other
elements</li>
<li>See full diff in <a
href="https://github.com/agronholm/typeguard/compare/4.1.1...4.1.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=typeguard&package-manager=pip&previous-version=4.1.1&new-version=4.1.2)](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] <support@github.com>
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
Projects
None yet
Development

No branches or pull requests

1 participant