Skip to content

Commit 92201f7

Browse files
abhiraj75audiodude
authored andcommitted
Add type hints to release, category, review, and namespace models
1 parent c4917dc commit 92201f7

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

wp1/models/wp10/category.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import attr
2+
from typing import Optional
23

34

45
@attr.s
56
class Category:
67
table_name = "categories"
78

8-
c_project = attr.ib()
9-
c_type = attr.ib()
10-
c_rating = attr.ib()
11-
c_replacement = attr.ib(default=None)
12-
c_category = attr.ib(default=None)
13-
c_ranking = attr.ib(default=None)
9+
c_project: bytes = attr.ib()
10+
c_type: bytes = attr.ib()
11+
c_rating: bytes = attr.ib()
12+
c_replacement: Optional[bytes] = attr.ib(default=None)
13+
c_category: Optional[bytes] = attr.ib(default=None)
14+
c_ranking: Optional[int] = attr.ib(default=None)

wp1/models/wp10/namespace.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import enum
2-
2+
from typing import Optional
33
import attr
44

55

@@ -13,8 +13,8 @@ class NsType(enum.Enum):
1313
class Namespace:
1414
table_name = "namespacename"
1515

16-
domain = attr.ib()
17-
ns_name = attr.ib()
18-
ns_type = attr.ib()
19-
ns_id = attr.ib(default=None)
20-
dbname = attr.ib(default=None)
16+
domain: bytes = attr.ib()
17+
ns_name: bytes = attr.ib()
18+
ns_type: NsType = attr.ib()
19+
ns_id: Optional[int] = attr.ib(default=None)
20+
dbname: Optional[bytes] = attr.ib(default=None)

wp1/models/wp10/release.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
class Release:
66
table_name = "releases"
77

8-
rel_article = attr.ib()
9-
rel_0p5_category = attr.ib()
10-
rel_0p5_timestamp = attr.ib()
8+
rel_article: bytes = attr.ib()
9+
rel_0p5_category: bytes = attr.ib()
10+
rel_0p5_timestamp: bytes = attr.ib()

wp1/models/wp10/review.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
from sqlalchemy import Column
22
from sqlalchemy.dialects.mysql import BINARY
3+
from typing import Optional
34

45
from wp1.wp10_db import Base
56

67

78
class Review(Base):
89
__tablename__ = "reviews"
910

10-
value = Column("rev_value", BINARY(10))
11-
article = Column("rev_article", BINARY(255), primary_key=True)
12-
timestamp = Column("rev_timestamp", BINARY(20))
11+
value: Optional[bytes] = Column("rev_value", BINARY(10))
12+
article: bytes = Column("rev_article", BINARY(255), primary_key=True)
13+
timestamp: Optional[bytes] = Column("rev_timestamp", BINARY(20))
1314

14-
def __repr__(self):
15+
def __repr__(self) -> str:
1516
return "<Review(value=%r, article=%r, timestamp=%r)>" % (
1617
self.value,
1718
self.article,

0 commit comments

Comments
 (0)