Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation about regex backslash-doubling doesn't work as expected #48

Closed
MattF-NSIDC opened this issue Aug 14, 2023 · 1 comment · Fixed by #52
Closed

Documentation about regex backslash-doubling doesn't work as expected #48

MattF-NSIDC opened this issue Aug 14, 2023 · 1 comment · Fixed by #52
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@MattF-NSIDC
Copy link

MattF-NSIDC commented Aug 14, 2023

  • bump-my-version version: 0.9.2
  • Python version: 3.10
  • Operating System: Pop!_OS 22

Description

I'm trying to get my repo's CITATION.cff file to automatically update both the version string and release date.

What I Did

Based on the docs, I should be doubling both my braces and backslashes when writing a regex:

[[tool.bumpversion.files]]
filename = "CITATION.cff"
search = 'date-released: "\\d{{4}}-\\d{{2}}-\\d{{2}}"'
replace = 'date-released: "{now:%Y-%m-%d}"'

This doesn't behave as expected. In my logs:

Searching for the regex: 'date-released: "\\d{4}-\\d{2}-\\d{2}"'                                                                               
Searching for the regex: 'date-released: "\\d{4}-\\d{2}-\\d{2}"'                                                                               
Not changing file CITATION.cff                                                                                                                 

The braces were behaving as expected with Python formatting -- doubling them results in a literal brace. But the backslashes are coming through exactly as I entered them in my TOML config.

After changing to single backslashes, I get the behavior I expected:

Searching for the regex: 'date-released: "\d{4}-\d{2}-\d{2}"'                                                                                  
Changing file CITATION.cff:                                                                                                                    
*** before CITATION.cff                                                                                                                        
--- after CITATION.cff             
***************                    
*** 22,28 ****                     
  repository-code: "https://github.com/nsidc/qgreenland"               

  version: "3.0.0alpha5"           
! date-released: "2023-08-23"      

  authors:                         
  - family-names: "*Fisher"        
--- 22,28 ----                     
  repository-code: "https://github.com/nsidc/qgreenland"               

  version: "3.0.0alpha5"           
! date-released: "2023-08-14"      

  authors:                         
  - family-names: "*Fisher"        
@coordt coordt added bug Something isn't working documentation Improvements or additions to documentation labels Aug 16, 2023
@coordt
Copy link
Member

coordt commented Aug 16, 2023

I'll fix the documentation. I double-checked my tests and I don't use double backslashes there either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants