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

Python: Rename StrConst to StringLiteral #16245

Merged
merged 7 commits into from
Apr 23, 2024

Conversation

tausbn
Copy link
Contributor

@tausbn tausbn commented Apr 17, 2024

Finishes the job that #9852 started, renaming Str and StrConst into StringLiteral, and deprecating the former two classes. Moreover, the toString of StringLiteral is overridden so that it returns the correct string. This ensures that the AST viewer shows the correct class for all strings in the source code.

Reviewing commit-by-commit is recommended.

tausbn added 6 commits April 22, 2024 12:00
Does a few things:
- Renames `StrConst` to `StringLiteral`, and deprecates the former.
- Also deprecates `Str`.
- Adds an override of `StringLiteral::toString` making it output
`"StringLiteral"` rather than the inherited `"Str"`. This ensures that
the AST viewer shows these nodes as the former type, not the latter.

There are a large number of uses of `StrConst` in the codebase. These
will be fixed in a later commit.
Done using
```
git grep StrConst | xargs sed -i 's/StrConst/StringLiteral/g'
```
Of course, `StringLiteral` being much longer than `StrConst` meant a
bunch of files changed formatting.
As far as I can tell, this was the only occurrence of `Str` as a type
throughout the entire library.
I'm beginning to realise why I didn't do the `toString` overriding way
back when. Thankfully, now that all of our tests are in the same place,
this is actually not a terrible ordeal.
@tausbn tausbn force-pushed the tausbn/python-rename-StrConst-to-StringLiteral branch from 5d1fca8 to bab461f Compare April 22, 2024 12:00
@tausbn tausbn marked this pull request as ready for review April 22, 2024 12:50
@tausbn tausbn requested a review from a team as a code owner April 22, 2024 12:50
Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

LGTM 👍 (I only skimmed through rename + expected file changes)

@RasmusWL RasmusWL merged commit 19974f0 into main Apr 23, 2024
15 checks passed
@RasmusWL RasmusWL deleted the tausbn/python-rename-StrConst-to-StringLiteral branch April 23, 2024 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants