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

Mark mangled globals as TypeAlias #607

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Apr 24, 2024

Closes #600

  • Mark top-level mangled identifiers as TypeAlias. (Y026)
  • Change the top-level mangling prefix from global___ to Global___ to respect Y042 naming convention.

Refs https://github.com/PyCQA/flake8-pyi/blob/main/ERRORCODES.md#list-of-warnings

@nipunn1313
Copy link
Owner

mine works. What's the trouble you're seeing?

@Avasam
Copy link
Contributor Author

Avasam commented Apr 25, 2024

Just some initial setup stuff I had to work through. Like having my files in CRLF (because I cloned from Windows with autocrlf on... oops) messing up the script, then figuring out how to install and use pyenv. But I think I got it working now.

@Avasam Avasam force-pushed the typealias-mangled-globals branch 2 times, most recently from 5460524 to dad9126 Compare April 25, 2024 03:30
@Avasam
Copy link
Contributor Author

Avasam commented Apr 25, 2024

Ah, if it ends end raising Y042 instead, I don't know if that's much better. Maybe a little bit since they don't seem to exist at runtime
Speaking of which, what are they exactly, the global___s ? It seems they can only be used for typing in TYPE_CHECKING context?

Module level identifiers are mangled and aliased so that they can be disambiguated
from fields/enum variants with the same name within the file.

Wouldn't they be better prefixed __ ? (to actually name-mangle and private them, would pass stubtest, and would also respect Y042 I believe)

@Avasam
Copy link
Contributor Author

Avasam commented Apr 25, 2024

And now unused type aliases are (rightfully) detected by Y047 ^^"
I feel like that's a nice-to-fix for another time, I'll reintroduce the stubtest entry and simply rename global___ to Global___

@nipunn1313
Copy link
Owner

Yep this all seems reasonable! Prefixing with __ also sounds great instead of Global__, but can save that for another day. Thanks for the contribution!

I'll try to tie up a few more fixes/updates and then release.

@nipunn1313 nipunn1313 merged commit d91d1df into nipunn1313:main Apr 25, 2024
6 checks passed
@Avasam Avasam deleted the typealias-mangled-globals branch April 25, 2024 17:40
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.

google.protobuf.any_pb2.global__Any is not marked as TypeAlias
2 participants