Skip to content

Commit 688a235

Browse files
committed
Refactor dataclass fields in AuthContext and Credentials for improved privacy and representation
1 parent 184f639 commit 688a235

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pyoverkiz/auth/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
import datetime
66
from collections.abc import Mapping
7-
from dataclasses import dataclass
7+
from dataclasses import dataclass, field
88
from typing import Any, Protocol
99

1010

1111
@dataclass(slots=True)
1212
class AuthContext:
1313
"""Authentication context holding tokens and expiration."""
1414

15-
access_token: str | None = None
16-
refresh_token: str | None = None
15+
access_token: str | None = field(default=None, repr=False)
16+
refresh_token: str | None = field(default=None, repr=False)
1717
expires_at: datetime.datetime | None = None
1818

1919
def is_expired(self, *, skew_seconds: int = 5) -> bool:

pyoverkiz/auth/credentials.py

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

33
from __future__ import annotations
44

5-
from dataclasses import dataclass
5+
from dataclasses import dataclass, field
66

77

88
class Credentials:
@@ -14,14 +14,14 @@ class UsernamePasswordCredentials(Credentials):
1414
"""Credentials using username and password."""
1515

1616
username: str
17-
password: str
17+
password: str = field(repr=False)
1818

1919

2020
@dataclass(slots=True)
2121
class TokenCredentials(Credentials):
2222
"""Credentials using an (API) token."""
2323

24-
token: str
24+
token: str = field(repr=False)
2525

2626

2727
@dataclass(slots=True)
@@ -33,5 +33,5 @@ class LocalTokenCredentials(TokenCredentials):
3333
class RexelOAuthCodeCredentials(Credentials):
3434
"""Credentials using Rexel OAuth2 authorization code."""
3535

36-
code: str
36+
code: str = field(repr=False)
3737
redirect_uri: str

pyoverkiz/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def select_first_attribute_value(self, attributes: list[str]) -> StateType | Non
475475
class Action:
476476
"""An action consists of multiple commands related to a single device, identified by its device URL."""
477477

478-
device_url: str
478+
device_url: str = field(repr=obfuscate_id)
479479
commands: list[Command] = field(factory=list)
480480

481481
def to_payload(self) -> dict[str, object]:

0 commit comments

Comments
 (0)