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 issueI 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:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top 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 >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
Yeah, we should remove
Nested
here but this requires bumping minimum marshmallow version, so I suppose it’ll wait until next major webargs version.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 latestmarshmallow
version.We also may have cleanup to do in
webargs
, but it should not impact users.