Merge pull request #148 from Neradoc/ignore-type-annotations-for-dunders

fix reading __version__ and __repo__ with type annotations
This commit is contained in:
foamyguy 2022-07-05 08:52:18 -05:00 committed by GitHub
commit b7a28e6d3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -512,7 +512,7 @@ def extract_metadata(path):
with open(path, encoding="utf-8") as source_file:
content = source_file.read()
#: The regex used to extract ``__version__`` and ``__repo__`` assignments.
dunder_key_val = r"""(__\w+__)\s*=\s*(?:['"]|\(\s)(.+)['"]"""
dunder_key_val = r"""(__\w+__)(?:\s*:\s*\w+)?\s*=\s*(?:['"]|\(\s)(.+)['"]"""
for match in re.findall(dunder_key_val, content):
result[match[0]] = str(match[1])
if result: