File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -115,3 +115,4 @@ venv.bak/
115
115
.rss-parser
116
116
.ruff_cache
117
117
.python-version
118
+ .DS_Store
Original file line number Diff line number Diff line change 1
1
[tool .poetry ]
2
2
name = " rss-parser"
3
- version = " 2.1.0 "
3
+ version = " 2.1.1 "
4
4
description = " Typed pythonic RSS/Atom parser"
5
5
authors = [" dhvcc <1337kwiz@gmail.com>" ]
6
6
license = " GPL-3.0"
Original file line number Diff line number Diff line change 1
- from typing import Union
1
+ from typing import Generic , TypeVar , Union
2
2
3
3
from rss_parser .pydantic_proxy import import_v1_pydantic
4
4
5
5
pydantic_validators = import_v1_pydantic (".validators" )
6
6
7
+ T = TypeVar ("T" )
7
8
8
- class OnlyList (list ):
9
+
10
+ class OnlyList (list , Generic [T ]):
9
11
@classmethod
10
12
def __get_validators__ (cls ):
11
13
yield cls .validate
@@ -14,8 +16,8 @@ def __get_validators__(cls):
14
16
@classmethod
15
17
def validate (cls , v : Union [dict , list ]):
16
18
if isinstance (v , list ):
17
- return v
18
- return [v ]
19
+ return cls ( v )
20
+ return cls ( [v ])
19
21
20
22
def __repr__ (self ):
21
23
return f"OnlyList({ super ().__repr__ ()} )"
You can’t perform that action at this time.
0 commit comments