Skip to content

Commit 89e3d2e

Browse files
toriningenZac-HD
andauthored
Fix IsDigit -> IsDigits (#63)
* Fix IsDigit -> IsDigits * fix IsDigit typo, leave alias --------- Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
1 parent 59a50d1 commit 89e3d2e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

annotated_types/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class Predicate(BaseMetadata):
305305
306306
We provide a few predefined predicates for common string constraints:
307307
``IsLower = Predicate(str.islower)``, ``IsUpper = Predicate(str.isupper)``, and
308-
``IsDigit = Predicate(str.isdigit)``. Users are encouraged to use methods which
308+
``IsDigits = Predicate(str.isdigit)``. Users are encouraged to use methods which
309309
can be given special handling, and avoid indirection like ``lambda s: s.lower()``.
310310
311311
Some libraries might have special logic to handle certain predicates, e.g. by
@@ -354,7 +354,8 @@ def __call__(self, __v: Any) -> bool:
354354
355355
A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.
356356
""" # noqa: E501
357-
IsDigits = Annotated[_StrType, Predicate(str.isdigit)]
357+
IsDigit = Annotated[_StrType, Predicate(str.isdigit)]
358+
IsDigits = IsDigit # type: ignore # plural for backwards compatibility, see #63
358359
"""
359360
Return True if the string is a digit string, False otherwise.
360361

annotated_types/test_cases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def cases() -> Iterable[Case]:
121121

122122
yield Case(at.LowerCase[str], ['abc', 'foobar'], ['', 'A', 'Boom'])
123123
yield Case(at.UpperCase[str], ['ABC', 'DEFO'], ['', 'a', 'abc', 'AbC'])
124-
yield Case(at.IsDigits[str], ['123'], ['', 'ab', 'a1b2'])
124+
yield Case(at.IsDigit[str], ['123'], ['', 'ab', 'a1b2'])
125125
yield Case(at.IsAscii[str], ['123', 'foo bar'], ['£100', '😊', 'whatever 👀'])
126126

127127
yield Case(Annotated[int, at.Predicate(lambda x: x % 2 == 0)], [0, 2, 4], [1, 3, 5])

0 commit comments

Comments
 (0)