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.

Strange warning from PyCharm: Unexpected type(s): (Dict[str, String]) Possible type(s): (Union[SchemaABC, type, str, () -> SchemaABC]) (Union[SchemaABC, type, str, () -> SchemaABC])

See original GitHub issue

I get this warning in PyCharm when using webargs to create a nested dictionary object:

data_args = {
    "name": fields.Nested(
        {"first": fields.Str(required=True), "last": fields.Str(required=True)}
    )
}

It happens for this line:

{"first": fields.Str(required=True), "last": fields.Str(required=True)}

Code is taken from the official webargs tutorial:

Why is PyCharm warning me about this and what should be the correct course of action?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lafrechcommented, Mar 15, 2022

Yeah, we should remove Nested here but this requires bumping minimum marshmallow version, so I suppose it’ll wait until next major webargs version.

0reactions
sirosencommented, Mar 15, 2022

In the past few days, marshmallow has done a release which should resolve this issue. You will need to ensure that pycharm (or any other type checker) is using the latest marshmallow version.

We also may have cleanup to do in webargs, but it should not impact users.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strange warning from PyCharm: Unexpected type(s): (Dict[str ...
Strange warning from PyCharm: Unexpected type(s): (Dict[str, String]) Possible type(s): (Union[SchemaABC, type, str, () -> SchemaABC]) ...
Read more >
False "Unexpected type(s)" warning : PY-36633 - YouTrack
Full warning: Unexpected type(s): (str) Possible types: (int) (slice). C# detected. Type of resp is declared like Union[Dict[str, Any], List[Any]] , so resp ......
Read more >
python - Unexpected type warning raised with list in PyCharm
In your case PyCharm sees you first line and thinks that the type of list is List[int] . I mean it is a...
Read more >
Unexpected type warning raised with list in PyCharm
PyCharm then return an error on both line 2 and line 4 as below: Unexpected type(s):(int, str)Possible type(s):(SupportsIndex, int)(slice, Iterable[int]).
Read more >
Why this pycharm warning for argparse formatter_class value?
ArgumentParser is of an "Unexpected type", ... Should I be concerned about this pycharm warning? ... sstargs = sstparser.parse_args().
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