sphinx-needs
sphinx-needs copied to clipboard
FIX: Use `re.fullmatch` for `needs_id_regex` in need creation
The regex supplied should be assumed to match the entire string, rather than be a partial match (as is the case currently using re.match).
This is then consistent with the usage of needs_id_regex in:
- https://github.com/useblocks/sphinx-needs/blob/1de1a7a047bfc7912ea0aa779ffb187def7a5254/sphinx_needs/directives/needextend.py#L111
-
- https://github.com/useblocks/sphinx-needs/blob/1de1a7a047bfc7912ea0aa779ffb187def7a5254/sphinx_needs/directives/needextract.py#L103
@danwos this now fails our docs build and some tests, because there it appears that regex is assumed to only be partial (only checking the start of the string).
So the question would be, do we instead change the code in needextend and needextract to use re.match, rather than re.fullmatch
Good point, I guess the user can reach fullmatch by using in the configured regex an ending $ right?
So yes, we should change it then also to match for needextend and co.