Skip to content

Commit

Permalink
Overload Password.__eq__
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Sep 3, 2022
1 parent cb1d831 commit b5cf71a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.3.2 (in development)
-----------------------
- Overload `Password.__eq__` so that instances continue to compare equal to
`pydantic.SecretStr` instances even under pydantic 1.10

v0.3.1 (2022-01-02)
-------------------
- Support tomli 2.0
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Changelog
=========

v0.3.2 (in development)
-----------------------
- Overload ``Password.__eq__`` so that instances continue to compare equal to
``pydantic.SecretStr`` instances even under pydantic 1.10

v0.3.1 (2022-01-02)
-------------------
- Support tomli 2.0
Expand Down
2 changes: 1 addition & 1 deletion src/outgoing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
more information.
"""

__version__ = "0.3.1"
__version__ = "0.3.2.dev1"
__author__ = "John Thorvald Wodder II"
__author_email__ = "outgoing@varonathe.org"
__license__ = "MIT"
Expand Down
10 changes: 8 additions & 2 deletions src/outgoing/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def __get_validators__(cls) -> "CallableGenerator":
yield path_resolve

class FilePath(pydantic.FilePath):
""" Like `Path`, but the path must exist and be a file """
"""Like `Path`, but the path must exist and be a file"""

@classmethod
def __get_validators__(cls) -> "CallableGenerator":
yield path_resolve
yield from super().__get_validators__()

class DirectoryPath(pydantic.DirectoryPath):
""" Like `Path`, but the path must exist and be a directory """
"""Like `Path`, but the path must exist and be a directory"""

@classmethod
def __get_validators__(cls) -> "CallableGenerator":
Expand Down Expand Up @@ -131,6 +131,12 @@ class MySender(pydantic.BaseModel):
host: ClassVar[Any] = None
username: ClassVar[Any] = None

def __eq__(self, other: Any) -> bool:
if isinstance(other, pydantic.SecretStr):
return self.get_secret_value() == other.get_secret_value()
else:
return NotImplemented

def __init_subclass__(cls) -> None:
if (
cls.host is not None
Expand Down

0 comments on commit b5cf71a

Please sign in to comment.