10000 Implement support for returning TypedDict for dataclasses.asdict by syastrov · Pull Request #8583 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Implement support for returning TypedDict for dataclasses.asdict #8583

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

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bb9f051
Implement support for returning TypedDict for dataclasses.asdict
syastrov Mar 26, 2020
e2f9f06
Remove redundant test. Fix comment typo.
syastrov Mar 26, 2020
2f6ec2d
Test for cases where dataclasses.asdict is called on non-dataclass in…
syastrov Mar 26, 2020
a9779e2
Clean up tests, and test more edge-cases.
syastrov Mar 26, 2020
c5d0a15
Remove no-longer-needed type: ignore on CheckerPluginInterface.module…
syastrov Mar 26, 2020
454431d
Make typeddicts non-total.
syastrov Mar 26, 2020
d809e8b
Address some of review comments (formatting, docs, code nitpicks, rem…
syastrov Mar 30, 2020
4d195cc
Simplify: Remove _transform_type_args and remove unneeded None check …
syastrov Mar 30, 2020
b33798c
Fix unused import
syastrov Mar 30, 2020
fe19bc9
Add fine-grained test for dataclasses.asdict.
syastrov Mar 30, 2020
6328a7c
Oops, add forgotten fine-grained dataclasses test. And remove redunda…
syastrov Mar 30, 2020
4694299
Only import the module containing TypedDict fallback if dataclasses i…
syastrov Apr 1, 2020
9c29081
Only enable TypedDict for Python >= 3.8.
syastrov Apr 2, 2020
d7df77a
Refactor asdict implementation to use TypeTranslator instead of recur…
syastrov Apr 2, 2020
e9a56ba
Made TypedDicts returned by asdict total again.
syastrov Apr 2, 2020
2e5240e
Fixed test after total change.
syastrov Apr 2, 2020
52a1c27
Make code a bit more readable, and a bit more robust.
syastrov Apr 2, 2020
43f174c
Fix typo
syastrov Apr 2, 2020
227ba90
After refactoring to use TypeTranslator, ensure Callable and Type[..]…
syastrov Apr 2, 2020
d12c665
Address second review comments.
syastrov Apr 8, 2020
45e72d7
Fix return type
syastrov Apr 8, 2020
a03f033
Try to address more review comments and fix flake8
syastrov Jun 3, 2020
b4d7e15
Add fine grained deps test to help debug asdict dependencies.
syastrov Jun 3, 2020
d96d977
Fix some asdict tests missing tuple dependency
syastrov Jun 3, 2020
441b665
Revert "Fix some asdict tests missing tuple dependency"
syastrov Jun 4, 2020
344ca6a
Don't need dep on typing_extensions
syastrov Jun 4, 2020
c8858fa
Checker lookup_fully_qualified_or_none: Don't raise KeyError, return …
syastrov Jun 9, 2020
20d7716
Add dependencies for asdict on the referenced dataclasses and its att…
syastrov Jun 9, 2020
5fec41b
Fix fine-grained no-cache test by adding correct dep on dataclass attrs.
syastrov Aug 18, 2020
5862c16
remove unused imports
syastrov Aug 18, 2020
26b7393
Merge branch 'master' into dataclasses-asdict
syastrov Feb 17, 2021
d7e0310
Remove error when passing a "non-dataclass" to asdict to reduce false…
syastrov Feb 17, 2021
080c00c
Fix flake8
syastrov Feb 17, 2021
9e45f8f
Fix asdict tests (require using python version 3.7 minimum).
syastrov Feb 17, 2021
38b466a
Merge branch 'master' into dataclasses-asdict
syastrov Aug 19, 2021
74ebc6f
Fix tests for quoting changes
syastrov Aug 19, 2021
aef274a
Merge branch 'master' into dataclasses-asdict
97littleleaf11 Nov 17, 2021
79f25db
Merge
97littleleaf11 Jan 18, 2022
f54e503
Fix
97littleleaf11 Jan 18, 2022
9820cfc
Add fixture for tests
97littleleaf11 Jan 18, 2022
9f49cac
Add fixture for tests
97littleleaf11 Jan 18, 2022
fcd1ff5
Add fixture for tests
97littleleaf11 Jan 18, 2022
9fa6a6b
Merge from master
97littleleaf11 Jan 18, 2022
10000
6e1585d
Fix
97littleleaf11 Jan 18, 2022
d6f9170
Merge branch 'master' of https://github.com/python/mypy into HEAD
97littleleaf11 Jan 19, 2022
e226562
Test for a workaround
97littleleaf11 Jan 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix flake8
  • Loading branch information
syastrov committed Feb 17, 2021
commit 080c00c2477b5283a7fe8fc4bedebaad4ebd76df
3 changes: 2 additions & 1 deletion mypy/semanal_typeddict.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,10 @@ def is_typeddict(self, expr: Expression) -> bool:
def fail(self, msg: str, ctx: Context, *, code: Optional[ErrorCode] = None) -> None:
self.api.fail(msg, ctx, code=code)


def get_anonymous_typeddict_type(
api: Union[SemanticAnalyzerInterface, CheckerPluginInterface]) -> Optional[Instance]:
# Prefer typing then typing_extensions if available.
return (api.named_type_or_none('typing._TypedDict', []) or
api.named_type_or_none('typing_extensions._TypedDict', []) or
api.named_type_or_none('mypy_extensions._TypedDict', []))
api.named_type_or_none('mypy_extensions._TypedDict', []))
0