From 5269c31fc49ee01a68b97fe78531e14211cf55ad Mon Sep 17 00:00:00 2001 From: Nicholas Wiltsie Date: Wed, 2 Oct 2024 11:37:59 -0700 Subject: [PATCH] Support type-hinted python version string --- bumpchanges/updatefiles.py | 1 + tests/test_versionfiles.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/bumpchanges/updatefiles.py b/bumpchanges/updatefiles.py index 37320aa..7c5fd38 100644 --- a/bumpchanges/updatefiles.py +++ b/bumpchanges/updatefiles.py @@ -19,6 +19,7 @@ version # Literal `version` (?:__)? # Optional literal `__` (?P=vquote) # `'`, `"`, or nothing (back-reference to `vquote`) + (?:\s*:\s*str\b)? # Optional literal `: str` (for python typing) (?: \s* # Any whitespace [=:]? # `=`, `:`, or nothing diff --git a/tests/test_versionfiles.py b/tests/test_versionfiles.py index 6ac8815..7797ec9 100644 --- a/tests/test_versionfiles.py +++ b/tests/test_versionfiles.py @@ -24,6 +24,11 @@ """__version__ = 1.1.0""", """__version__ = 2.3.4""", ), + ( + # Python-style with typing + """__version__: str = '1.1.0'""", + """__version__: str = '2.3.4'""", + ), ( # Plain string version '''version = "1.1.0"''',