typing.Set is not supported
See original GitHub issue@add_schema
@dataclass
class Stuff:
id: str
items: Set[str]
The above fails with TypeError: typing.Set[str] is not a dataclass and cannot be turned into one.
I often use sets to ensure de-duplication, so it would be nice if it actually constructed a set
every time.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
typing — Support for type hints — Python 3.11.1 documentation
Source code: Lib/typing.py This module provides runtime support for type hints. The most fundamental support consists of the types Any, Union, Callable, ...
Read more >What's the best practice of typing hint after python 3.9?
You should be using the set[str] style of typing. Looking at PEP 585: Importing those from typing is deprecated. Due to PEP 563...
Read more >Implement PEP 585 (Generic builtins and __future__ ...
MyPy tells me "defaultdict" is not subscriptable, use "typing. ... Similarly, dict , set , tuple and frozenset shouldn't be subscriptable, ...
Read more >Type hinting in PyCharm - JetBrains
PyCharm supports type hinting in function annotations and type ... Type comments with unpacking do not match the corresponding targets.
Read more >Solved: Error in update set "Type change not allowed."Cann...
Solved: Hi Actually, I had 2 fields namely "Application" &"Original request" on exceptions table. Both are string fields. Now I.
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
let’s keep this open. Once the feature is implemented in marshmallow and we check it works with marshmallow dataclass, we’ll close this.
As a workaround (not for sets, but for the frozen aspect) you should be able to specify
frozen=False
in thedataclass
decorator. Of course this only works if you want every member of the instance to be immutable.