Skip to content

Commit 0c607a7

Browse files
committed
v2.1.1 Fix improper generic setup for mypy #51
1 parent 3430603 commit 0c607a7

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,4 @@ venv.bak/
115115
.rss-parser
116116
.ruff_cache
117117
.python-version
118+
.DS_Store

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "rss-parser"
3-
version = "2.1.0"
3+
version = "2.1.1"
44
description = "Typed pythonic RSS/Atom parser"
55
authors = ["dhvcc <1337kwiz@gmail.com>"]
66
license = "GPL-3.0"

rss_parser/models/types/only_list.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
from typing import Union
1+
from typing import Generic, TypeVar, Union
22

33
from rss_parser.pydantic_proxy import import_v1_pydantic
44

55
pydantic_validators = import_v1_pydantic(".validators")
66

7+
T = TypeVar("T")
78

8-
class OnlyList(list):
9+
10+
class OnlyList(list, Generic[T]):
911
@classmethod
1012
def __get_validators__(cls):
1113
yield cls.validate
@@ -14,8 +16,8 @@ def __get_validators__(cls):
1416
@classmethod
1517
def validate(cls, v: Union[dict, list]):
1618
if isinstance(v, list):
17-
return v
18-
return [v]
19+
return cls(v)
20+
return cls([v])
1921

2022
def __repr__(self):
2123
return f"OnlyList({super().__repr__()})"

0 commit comments

Comments
 (0)