Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing updates for recent mypy versions #481

Merged
merged 4 commits into from Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/481.misc
@@ -0,0 +1 @@
Update type annotations to ensure Sydent typechecks with recent mypy versions.
3 changes: 1 addition & 2 deletions sydent/db/accounts.py
Expand Up @@ -104,7 +104,6 @@ def delToken(self, token: str) -> int:
"delete from tokens where token = ?",
(token,),
)
# Cast safety: DBAPI-2 says this is a "number"; c.f. python/typeshed#6150
deleted = cast(int, cur.rowcount)
deleted = cur.rowcount
self.sydent.db.commit()
return deleted
4 changes: 1 addition & 3 deletions sydent/db/invite_tokens.py
Expand Up @@ -137,9 +137,7 @@ def validateEphemeralPublicKey(self, publicKey: str) -> bool:
(publicKey,),
)
self.sydent.db.commit()
# Cast safety: DBAPI-2 says this is a "number"; c.f. python/typeshed#6150
rows = cast(int, cur.rowcount)
return rows > 0
return cur.rowcount > 0

def getSenderForToken(self, token: str) -> Optional[str]:
"""
Expand Down
3 changes: 2 additions & 1 deletion sydent/sydent.py
Expand Up @@ -339,8 +339,9 @@ def setup_logging(config: SydentConfig) -> None:
log_format = "%(asctime)s - %(name)s - %(lineno)d - %(levelname)s" " - %(message)s"
formatter = logging.Formatter(log_format)

handler: logging.Handler
if log_path != "":
handler: logging.StreamHandler = logging.handlers.TimedRotatingFileHandler(
handler = logging.handlers.TimedRotatingFileHandler(
log_path, when="midnight", backupCount=365
)
handler.setFormatter(formatter)
Expand Down