Skip to content

Commit

Permalink
ext/mutable/MutableBase: fix coerce type (#256)
Browse files Browse the repository at this point in the history
* tests: add test for issue #255

* ext/mutable/MutableBase: fix coerce type
Fixes #255
  • Loading branch information
huwcbjones authored Jul 11, 2023
1 parent ff4df35 commit d977292
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlalchemy-stubs/ext/mutable.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ from ..util import memoized_property as memoized_property

class MutableBase:
@classmethod
def coerce(cls, key: Any, value: Any) -> None: ...
def coerce(cls, key: str, value: Any) -> Any: ...

class Mutable(MutableBase):
def changed(self) -> None: ...
Expand Down
14 changes: 14 additions & 0 deletions test/files/issue_255.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from __future__ import annotations

from typing import Any

from sqlalchemy.ext.mutable import Mutable


class Issue255(Mutable):

@classmethod
def coerce(cls, key: str, value: Any) -> str | None:
if value is None:
return None
return str(value)

0 comments on commit d977292

Please sign in to comment.