Skip to content

Commit 0aa0d90

Browse files
Fixes #1164 - Add support for None typehint in Varchar length attribute (#1165)
* Add support for None typehint for length option in Varchar * fix linter warning --------- Co-authored-by: Daniel Townsend <[email protected]>
1 parent 0cdb6dc commit 0aa0d90

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

piccolo/apps/user/tables.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ async def login(cls, username: str, password: str) -> t.Optional[int]:
202202
The id of the user if a match is found, otherwise ``None``.
203203
204204
"""
205-
if len(username) > cls.username.length:
205+
if (max_username_length := cls.username.length) and len(
206+
username
207+
) > max_username_length:
206208
logger.warning("Excessively long username provided.")
207209
return None
208210

piccolo/columns/column_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class Band(Table):
315315

316316
def __init__(
317317
self,
318-
length: int = 255,
318+
length: t.Optional[int] = 255,
319319
default: t.Union[str, Enum, t.Callable[[], str], None] = "",
320320
**kwargs,
321321
) -> None:

0 commit comments

Comments
 (0)