question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning when using asdict on pydantic dataclasses

See original GitHub issue

Hello, 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:closed
  • Created 4 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
koxudaxicommented, Apr 11, 2020

@christophelec @samuelcolvin

PyCharm 2020.1 has released which can support third-party dataclass library like pydantic.dataclasses This plugin enables the feature, And PyCharm treats pydantic.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. screenshot20

3reactions
pauleverittcommented, Apr 11, 2020

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found