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

Fixes bug related to Tuples defined with ellipsis #440

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

matt035343
Copy link
Collaborator

PR #435 introduced a new bug that raises an exception when deserializing tuples defined with ellipsis (e.g. Tuple[str, ...]). This PR is fixing this issue.

@matt035343 matt035343 added the bug Something isn't working label Jul 19, 2023
@matt035343 matt035343 linked an issue Jul 19, 2023 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Jul 19, 2023

Coverage

Coverage Report
FileStmtsMissCoverMissing
dataclasses_json
   cfg.py51492%77, 81–83
   core.py234996%38–41, 51, 64, 66, 81, 83, 169
   mm.py1892985%33–36, 42–45, 53–56, 62–65, 88, 152–153, 158, 162, 166, 171, 175, 179, 187, 193, 198, 207, 212, 217, 235–242
   stringcase.py25388%59, 76, 97
   undefined.py143299%24, 38
   utils.py1282977%11–24, 44–49, 60–64, 74, 99–100, 108–109, 158, 177, 202
tests
   entities.py220299%229, 235
   test_annotations.py814248%50–67, 78–102, 106–122
   test_api.py142299%139–140
   test_str_subclass.py22195%9
TOTAL242212395% 

Tests Skipped Failures Errors Time
283 1 💤 0 ❌ 0 🔥 4.631s ⏱️

@matt035343 matt035343 merged commit ac20ad9 into master Jul 20, 2023
7 checks passed
@matt035343 matt035343 deleted the fix-ellipsis-bug branch July 20, 2023 07:42
@deansg
Copy link
Contributor

deansg commented Jul 20, 2023

The bug still seems to happen, I have a Tuple[str, ...] as a field in a class and just calling .schema() on it fails with the following message:
E TypeError: Field.__init__() takes 1 positional argument but 2 positional arguments (and 3 keyword-only arguments) were given

@deansg
Copy link
Contributor

deansg commented Jul 20, 2023

Full code to reproduce on Python 3.10 (very straightforward):

@dataclass_json
@dataclass
class SomeClass:
    tags: Tuple[str, ...] = None


def test_foo():
    SomeClass.schema()

@matt035343
Copy link
Collaborator Author

matt035343 commented Jul 20, 2023

Hi @deansg. If I am not mistaken, this seems to be related to an old issue (#398 and #432) not directly related to what has been discussed in #440 and #435. I will have a look at #398 soon.

renovate bot added a commit to ixm-one/pytest-cmake-presets that referenced this pull request Dec 10, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [dataclasses-json](https://togithub.com/lidatong/dataclasses-json)
([changelog](https://togithub.com/lidatong/dataclasses-json/releases)) |
`^0.5.7` -> `^0.6.0` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/dataclasses-json/0.6.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/dataclasses-json/0.6.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/dataclasses-json/0.5.9/0.6.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/dataclasses-json/0.5.9/0.6.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the warning logs for
more information.

---

### Release Notes

<details>
<summary>lidatong/dataclasses-json (dataclasses-json)</summary>

###
[`v0.6.3`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.6.3)

[Compare
Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.6.2...v0.6.3)

#### What's Changed

- Fixes catchall inheritance issue by
[@&#8203;jasonrock-a3](https://togithub.com/jasonrock-a3) in
[lidatong/dataclasses-json#500

#### New Contributors

- [@&#8203;jasonrock-a3](https://togithub.com/jasonrock-a3) made their
first contribution in
[lidatong/dataclasses-json#500

**Full Changelog**:
lidatong/dataclasses-json@v0.6.2...v0.6.3

###
[`v0.6.2`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.6.2)

[Compare
Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.6.1...v0.6.2)

#### What's Changed

- fix: allow using CatchAll with postponed evaluation of annotations by
[@&#8203;2ynn](https://togithub.com/2ynn) in
[lidatong/dataclasses-json#490
- Fix PEP 0673 before 3.11 by
[@&#8203;george-zubrienko](https://togithub.com/george-zubrienko) in
[lidatong/dataclasses-json#487
- fix mypy error when assigning to dataclass_json_config by
[@&#8203;MickaelBergem](https://togithub.com/MickaelBergem) in
[lidatong/dataclasses-json#486
- Fix an issue introduced with hetero tuple decode by
[@&#8203;george-zubrienko](https://togithub.com/george-zubrienko) in
[lidatong/dataclasses-json#493

#### New Contributors

- [@&#8203;2ynn](https://togithub.com/2ynn) made their first
contribution in
[lidatong/dataclasses-json#490
- [@&#8203;MickaelBergem](https://togithub.com/MickaelBergem) made their
first contribution in
[lidatong/dataclasses-json#486

**Full Changelog**:
lidatong/dataclasses-json@v0.6.1...v0.6.2

###
[`v0.6.1`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.6.1)

[Compare
Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.6.0...v0.6.1)

##### What's Changed

- Add links to make PyPI a better maintainer reference by
[@&#8203;pydanny](https://togithub.com/pydanny) in
[lidatong/dataclasses-json#482
- improve Union deserialization when "\__type" field specifier is not
present by [@&#8203;idbentley](https://togithub.com/idbentley) in
[lidatong/dataclasses-json#478

##### New Contributors

- [@&#8203;pydanny](https://togithub.com/pydanny) made their first
contribution in
[lidatong/dataclasses-json#482
- [@&#8203;idbentley](https://togithub.com/idbentley) made their first
contribution in
[lidatong/dataclasses-json#478

**Full Changelog**:
lidatong/dataclasses-json@v0.6.0...v0.6.1

###
[`v0.6.0`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.6.0)

[Compare
Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.5.14...v0.6.0)

##### What's Changed

- Improve dataclass_json and \_process_class type annotations by
[@&#8203;ringohoffman](https://togithub.com/ringohoffman) in
[lidatong/dataclasses-json#475
- Update Poetry version used for 3.7 test suite and change
Requires-Python boundary by
[@&#8203;george-zubrienko](https://togithub.com/george-zubrienko) in
[lidatong/dataclasses-json#476
- Fix for
[#&#8203;239](https://togithub.com/lidatong/dataclasses-json/issues/239):
Union inside List or Dict is not deserialized as the correspond… by
[@&#8203;pawelwilczewski](https://togithub.com/pawelwilczewski) in
[lidatong/dataclasses-json#464

Due to a behaviour change discovered in
[lidatong/dataclasses-json#466
and also as a matter of preparation for full deprecation of Py3.7, we
are bumping the minor version to 0.6.0. Most important change is that
since 0.5.9 builtins are coerced automatically without throwing an
exception. Please visit the issue for more info :)

##### New Contributors

- [@&#8203;ringohoffman](https://togithub.com/ringohoffman) made their
first contribution in
[lidatong/dataclasses-json#475
- [@&#8203;pawelwilczewski](https://togithub.com/pawelwilczewski) made
their first contribution in
[lidatong/dataclasses-json#464

**Full Changelog**:
lidatong/dataclasses-json@v0.5.15...v0.6.0

###
[`v0.5.14`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.5.14)

[Compare
Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.5.13...v0.5.14)

#### What's Changed

- Temporarily disable code coverage publish for fork PRs by
[@&#8203;george-zubrienko](https://togithub.com/george-zubrienko) in
[lidatong/dataclasses-json#444
- fix mashmallow fields.Tuple creation by
[@&#8203;healthmatrice](https://togithub.com/healthmatrice) in
[lidatong/dataclasses-json#434
- Allow the global config dictionary keys to also be Optional\[type] by
[@&#8203;sumnerevans](https://togithub.com/sumnerevans) in
[lidatong/dataclasses-json#255
- Fix global_config.mm_fields having no effect by
[@&#8203;sigmunau](https://togithub.com/sigmunau) in
[lidatong/dataclasses-json#253
- Fixes recursion bug related to enum flags by
[@&#8203;matt035343](https://togithub.com/matt035343) in
[lidatong/dataclasses-json#447
- Update Python version boundaries to include 3.12 by
[@&#8203;cdce8p](https://togithub.com/cdce8p) in
[lidatong/dataclasses-json#449

#### New Contributors

- [@&#8203;healthmatrice](https://togithub.com/healthmatrice) made their
first contribution in
[lidatong/dataclasses-json#434
- [@&#8203;sigmunau](https://togithub.com/sigmunau) made their first
contribution in
[lidatong/dataclasses-json#253
- [@&#8203;cdce8p](https://togithub.com/cdce8p) made their first
contribution in
[lidatong/dataclasses-json#449

**Full Changelog**:
lidatong/dataclasses-json@v0.5.13...v0.5.14

###
[`v0.5.13`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.5.13)

[Compare
Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.5.12...v0.5.13)

#### What's Changed

- Fixes bug related to Tuples defined with ellipsis by
[@&#8203;matt035343](https://togithub.com/matt035343) in
[lidatong/dataclasses-json#440
- Revert type hint in annotation call by
[@&#8203;george-zubrienko](https://togithub.com/george-zubrienko) in
[lidatong/dataclasses-json#441

**Full Changelog**:
lidatong/dataclasses-json@v0.5.12...v0.5.13

###
[`v0.5.12`](https://togithub.com/lidatong/dataclasses-json/releases/tag/v0.5.12)

[Compare
Source](https://togithub.com/lidatong/dataclasses-json/compare/v0.5.9...v0.5.12)

#### What's Changed

- Fix multiline scripts in CI by
[@&#8203;george-zubrienko](https://togithub.com/george-zubrienko) in
[lidatong/dataclasses-json#439

**Full Changelog**:
lidatong/dataclasses-json@v0.5.11...v0.5.12

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ixm-one/pytest-cmake-presets).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi43OS4xIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Izzy Muerte <63051+bruxisma@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Izzy Muerte <63051+bruxisma@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] tuple decode assumes homogenous sequence
3 participants