question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't replace version numbers of *partial* matches

See original GitHub issue

Given a setup.py file containing those two lines:

if pkg_resources.get_distribution("setuptools").version < "40.1.1":

# ... other lines

    version="0.1.1",

If you bump the version (the patch for example), it will modify 40.1.1 to 40.1.2. This is because it’s a simple replace using the current version. It probably should use a regex to find the version the file. The only work around I found was to the change the search to include the double quotes.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
florislacommented, Jan 27, 2020

I’m not working on a fix, but here is a unit test which demonstrates the problem.

https://github.com/florisla/bump2version/tree/dont-replace-partial-matches

1reaction
florislacommented, Jan 27, 2020

This is not very trivial to fix since the current utils.ConfiguredFile.replace() does not use regular expressions (re.sub). It’s simply serializing the search and replace text, and doing str.replace on the whole file content.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Regex to not match partial sequences, but match full ones
I'm trying to match and replace full escape sequences like ' but not partial, like 39 , since 39 is not actually in...
Read more >
Substitutions in Regular Expressions | Microsoft Learn
Make substitutions to replace matched text using regular expressions in .NET. Substitutions are language elements recognized only within ...
Read more >
Excel IF statement for partial text match (wildcard) - Ablebits
The tutorial shows how to make Excel IF statement with wildcard text and get it to work for partial matches.
Read more >
perlrequick - Perl regular expressions quick start
A failed match or changing the target string resets the position. If you don't want the position reset after failure to match, add...
Read more >
Regular Expression Examples - the Tcler's Wiki!
Janos Holanyi: I would really need to build up a re that would match one line and ... If you don't mind a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found