Warning when using asdict on pydantic dataclasses
See original GitHub issueHello, and thanks for the plugin
When using the regular dataclass method asdict on a pydantic dataclass, I get the following warning on Pycharm :
'dataclasses.asdict' method should be called on dataclass instances
Since pydantic dataclasses are a drop in replacement for dataclasses, it works fine when it is run, so I think the warning should be removed if possible (I’m unfamiliar with Pycharm plugins)
I’m using PyCharm pro 2019.2, with the pydantic plugin in version 0.0.14
To reproduce the issue, open a python file in Pycharm and type:
from pydantic.dataclasses import dataclass
from dataclasses import asdict
@dataclass
class Test:
i: int
test_dataclass = Test(0)
asdict(test_dataclass)
You will see the warning above on test_dataclass
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
Warning when using asdict on pydantic dataclasses : PY-37802
pydantic dataclass needs dataclasses.asdict to dump a dict object. However, PyCharm shows a warning. 'dataclasses.asdict' method should be called on dataclass ...
Read more >Dataclasses - pydantic
Warning. After v1.2, The Mypy plugin must be installed to type check pydantic dataclasses. For more information about combining validators with dataclasses, ...
Read more >Python dataclass from a nested dict - Stack Overflow
I'm the author of dacite - the tool that simplifies creation of data classes from dictionaries. This library has only one function from_dict ......
Read more >How to use the dataclasses.asdict function in dataclasses - Snyk
To help you get started, we've selected a few dataclasses.asdict examples, based on popular ways it is used in public projects.
Read more >Dataclass Wizard — Dataclass Wizard 0.22.2 documentation
JSON to Dataclass generation: construct a dataclass schema with a JSON file or ... date from dataclass_wizard import fromdict, asdict, DumpMeta @dataclass ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@christophelec @samuelcolvin
PyCharm 2020.1 has released which can support third-party dataclass library like
pydantic.dataclasses
This plugin enables the feature, And PyCharm treatspydantic.dataclasses
as a third-party plugin. The feature is enabled on plugin version 0.1.0 or later.Also, Jetbrains developer Semyon Proshev(@sproshev) designed and implemented the feature to PyCharm for communities like us.
Thank you very much.
I put an image which is resolved the problem of the first post.
@koxudaxi I’ve been watching all of the fixes and improvements you’ve done, waiting for this time when the PyCharm side ships what’s needed. I can finally ask: can we do a PyCharm blog post interview with you about this?