Description
The default regex to find the __version__ or VERSION variable in the file specified in hatch.version.path does not currently handle typing. For example:
This works:
This fails with ValueError: Error getting the version from source regex: unable to parse the version from the file:
__version__: str = "1.0.0"
Modifying the default regex with the below setting in pyproject.toml works in both cases:
[tool.hatch.version]
pattern = "(?i)^(__version__|VERSION)(?:: *str)? *= *([\\'\"])v?(?P<version>.+?)\\2"
This change should be fairly safe, the only reason I'm not submitting a PR is because my use case requires Python 3.7 so I'm working with an old version of hatch (1.17.1).
Use case/motivation
Adding type annotations is best current practice and is increasingly common. Supporting them in the default regex statement would prevent a lot of developers from having to troubleshoot and fix this common case when setting up/migrating their projects.
Related issues
No response
Are you willing to submit a PR?
Code of Conduct
Description
The default regex to find the
__version__orVERSIONvariable in the file specified inhatch.version.pathdoes not currently handle typing. For example:This works:
This fails with
ValueError: Error getting the version from sourceregex: unable to parse the version from the file:Modifying the default regex with the below setting in
pyproject.tomlworks in both cases:This change should be fairly safe, the only reason I'm not submitting a PR is because my use case requires Python 3.7 so I'm working with an old version of hatch (1.17.1).
Use case/motivation
Adding type annotations is best current practice and is increasingly common. Supporting them in the default regex statement would prevent a lot of developers from having to troubleshoot and fix this common case when setting up/migrating their projects.
Related issues
No response
Are you willing to submit a PR?
Code of Conduct