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

Allow patch constant to patch type like Option<T> and to replace comp… #30

Merged
merged 2 commits into from
May 20, 2024

Conversation

sydhds
Copy link
Collaborator

@sydhds sydhds commented May 14, 2024

…uted values

@sydhds sydhds requested a review from bilboquet May 14, 2024 12:47
@sydhds sydhds mentioned this pull request May 14, 2024
1 task
@@ -26,7 +26,7 @@ def apply(self, root=Path, strip: int = 0, fuzz: bool = False):
with open(root / self.constant_file, "r+") as fp:
content = fp.read()
content_sub = re.sub(
f"(pub )?const {self.constant_name}: (\w+) = (\w+);",
f"(pub )?const {self.constant_name}: ([\w\<\>]+) = ([\w\s\*\(\)]+);",
f"\g<1>const {self.constant_name}: \g<2> = {self.new_value};",
content,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
)
content_sub = re.sub(
f"(.* const {self.constant_name}[ :].*) = (.*);",
f"\g<1> = {self.new_value};",
content,
)

looks more readable to me
we capture the right member of the = sign as long as it contains the correct identifier
then we replace the whole line by <1> = new_value;

@bilboquet bilboquet merged commit bc1ba33 into main May 20, 2024
1 check failed
@bilboquet bilboquet deleted the feature/improve_patch_constant_1 branch May 20, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants