Skip to content

Commit 5c2b86f

Browse files
authored
replace @abstractproperty (#287)
1 parent f89bb57 commit 5c2b86f

File tree

4 files changed

+68
-36
lines changed

4 files changed

+68
-36
lines changed

piccolo_api/change_password/endpoints.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import typing as t
5-
from abc import ABCMeta, abstractproperty
5+
from abc import ABCMeta, abstractmethod
66
from json import JSONDecodeError
77

88
from jinja2 import Environment, FileSystemLoader
@@ -31,27 +31,33 @@
3131

3232

3333
class ChangePasswordEndpoint(HTTPEndpoint, metaclass=ABCMeta):
34-
@abstractproperty
34+
@property
35+
@abstractmethod
3536
def _login_url(self) -> str:
3637
raise NotImplementedError
3738

38-
@abstractproperty
39+
@property
40+
@abstractmethod
3941
def _change_password_template(self) -> Template:
4042
raise NotImplementedError
4143

42-
@abstractproperty
44+
@property
45+
@abstractmethod
4346
def _styles(self) -> Styles:
4447
raise NotImplementedError
4548

46-
@abstractproperty
49+
@property
50+
@abstractmethod
4751
def _session_table(self) -> t.Optional[t.Type[SessionsBase]]:
4852
raise NotImplementedError
4953

50-
@abstractproperty
54+
@property
55+
@abstractmethod
5156
def _session_cookie_name(self) -> t.Optional[str]:
5257
raise NotImplementedError
5358

54-
@abstractproperty
59+
@property
60+
@abstractmethod
5561
def _read_only(self) -> bool:
5662
raise NotImplementedError
5763

piccolo_api/jwt_auth/endpoints.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import typing as t
4-
from abc import abstractproperty
4+
from abc import abstractmethod
55
from datetime import datetime, timedelta, timezone
66

77
import jwt
@@ -13,15 +13,18 @@
1313

1414

1515
class JWTLoginBase(HTTPEndpoint):
16-
@abstractproperty
16+
@property
17+
@abstractmethod
1718
def _auth_table(self) -> t.Type[BaseUser]:
1819
raise NotImplementedError
1920

20-
@abstractproperty
21+
@property
22+
@abstractmethod
2123
def _secret(self) -> str:
2224
raise NotImplementedError
2325

24-
@abstractproperty
26+
@property
27+
@abstractmethod
2528
def _expiry(self) -> timedelta:
2629
raise NotImplementedError
2730

piccolo_api/register/endpoints.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import re
55
import typing as t
6-
from abc import ABCMeta, abstractproperty
6+
from abc import ABCMeta, abstractmethod
77
from json import JSONDecodeError
88

99
from jinja2 import Environment, FileSystemLoader
@@ -36,34 +36,41 @@
3636

3737

3838
class RegisterEndpoint(HTTPEndpoint, metaclass=ABCMeta):
39-
@abstractproperty
39+
@property
40+
@abstractmethod
4041
def _auth_table(self) -> t.Type[BaseUser]:
4142
raise NotImplementedError
4243

43-
@abstractproperty
44+
@property
45+
@abstractmethod
4446
def _redirect_to(self) -> t.Union[str, URL]:
4547
"""
4648
Where to redirect to after login is successful.
4749
"""
4850
raise NotImplementedError
4951

50-
@abstractproperty
52+
@property
53+
@abstractmethod
5154
def _register_template(self) -> Template:
5255
raise NotImplementedError
5356

54-
@abstractproperty
57+
@property
58+
@abstractmethod
5559
def _user_defaults(self) -> t.Optional[t.Dict[str, t.Any]]:
5660
raise NotImplementedError
5761

58-
@abstractproperty
62+
@property
63+
@abstractmethod
5964
def _captcha(self) -> t.Optional[Captcha]:
6065
raise NotImplementedError
6166

62-
@abstractproperty
67+
@property
68+
@abstractmethod
6369
def _styles(self) -> Styles:
6470
raise NotImplementedError
6571

66-
@abstractproperty
72+
@property
73+
@abstractmethod
6774
def _read_only(self) -> bool:
6875
raise NotImplementedError
6976

piccolo_api/session_auth/endpoints.py

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import typing as t
55
import warnings
6-
from abc import ABCMeta, abstractproperty
6+
from abc import ABCMeta, abstractmethod
77
from datetime import datetime, timedelta
88
from json import JSONDecodeError
99

@@ -39,23 +39,28 @@
3939

4040

4141
class SessionLogoutEndpoint(HTTPEndpoint, metaclass=ABCMeta):
42-
@abstractproperty
42+
@property
43+
@abstractmethod
4344
def _session_table(self) -> t.Type[SessionsBase]:
4445
raise NotImplementedError
4546

46-
@abstractproperty
47+
@property
48+
@abstractmethod
4749
def _cookie_name(self) -> str:
4850
raise NotImplementedError
4951

50-
@abstractproperty
52+
@property
53+
@abstractmethod
5154
def _redirect_to(self) -> t.Optional[str]:
5255
raise NotImplementedError
5356

54-
@abstractproperty
57+
@property
58+
@abstractmethod
5559
def _logout_template(self) -> Template:
5660
raise NotImplementedError
5761

58-
@abstractproperty
62+
@property
63+
@abstractmethod
5964
def _styles(self) -> t.Optional[Styles]:
6065
raise NotImplementedError
6166

@@ -102,53 +107,64 @@ async def post(self, request: Request) -> Response:
102107

103108

104109
class SessionLoginEndpoint(HTTPEndpoint, metaclass=ABCMeta):
105-
@abstractproperty
110+
@property
111+
@abstractmethod
106112
def _auth_table(self) -> t.Type[BaseUser]:
107113
raise NotImplementedError
108114

109-
@abstractproperty
115+
@property
116+
@abstractmethod
110117
def _session_table(self) -> t.Type[SessionsBase]:
111118
raise NotImplementedError
112119

113-
@abstractproperty
120+
@property
121+
@abstractmethod
114122
def _session_expiry(self) -> timedelta:
115123
raise NotImplementedError
116124

117-
@abstractproperty
125+
@property
126+
@abstractmethod
118127
def _max_session_expiry(self) -> timedelta:
119128
raise NotImplementedError
120129

121-
@abstractproperty
130+
@property
131+
@abstractmethod
122132
def _cookie_name(self) -> str:
123133
raise NotImplementedError
124134

125-
@abstractproperty
135+
@property
136+
@abstractmethod
126137
def _redirect_to(self) -> t.Optional[str]:
127138
"""
128139
Where to redirect to after login is successful.
129140
"""
130141
raise NotImplementedError
131142

132-
@abstractproperty
143+
@property
144+
@abstractmethod
133145
def _production(self) -> bool:
134146
"""
135147
If True, apply more stringent security.
136148
"""
137149
raise NotImplementedError
138150

139-
@abstractproperty
151+
@property
152+
@abstractmethod
140153
def _login_template(self) -> Template:
141154
raise NotImplementedError
142155

143-
@abstractproperty
156+
@property
157+
@abstractmethod
144158
def _hooks(self) -> t.Optional[LoginHooks]:
145159
raise NotImplementedError
146160

147-
@abstractproperty
161+
@property
162+
@abstractmethod
148163
def _captcha(self) -> t.Optional[Captcha]:
149164
raise NotImplementedError
150165

151-
@abstractproperty
166+
@property
167+
@abstractmethod
152168
def _styles(self) -> t.Optional[Styles]:
153169
raise NotImplementedError
154170

0 commit comments

Comments
 (0)