The global___ name mangling breaks my type check
See original GitHub issueWith mypy-protobuf 1.19, mypy passed my code. Upgrading to mypy-protobuf 1.20 changes the output to add some global___
prefixes to types, breaking the type check. If I pin my dependency to 1.19, or just strip out these prefixes, mypy passes my code again. Is there another alternative? Perhaps an option to disable the name mangling?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
questions about name mangling in C++ - Stack Overflow
When a global function is overloaded, the generated mangled name for each overloaded version is unique. Name mangling is also applied to ...
Read more >Why can't compilers use name mangling to manage an ABI ...
Where there is an ABI break (say with unique_ptr) why can't the compiler produce multiple versions of the symbol, one that is compatible...
Read more >UsesCgo exposes mangled names · Issue #39072 · golang/go
When UsesCgo is enabled, cgo symbols appear in the package as their mangled names, e.g. _CFunc_GoString. This breaks autocomplete in gopls ...
Read more >mikeash.com: Friday Q&A 2014-08-15: Swift Name Mangling
Swift's name mangling is somewhat different from C++'s. Swift uses an encoding clearly ... a.b.c.d , taking a bound parameter of type test....
Read more >Name mangling - Wikipedia
The need for name mangling arises where the language allows different entities to be named with the same identifier as long as they...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Excellent debugging! Thanks!
I changed
global__
totype__
since it was not actually always at global scope - while I was investigating this issue earlier.We do have a test case which creates a similar scenario here.
proto: https://github.com/dropbox/mypy-protobuf/blob/master/proto/test/proto/test3.proto#L32
generated pyi: https://github.com/dropbox/mypy-protobuf/blob/master/test/proto/test3_pb2.pyi.expected#L97
This seems to pass our tests, which does mypy over the generated
.pyi
file. This leads me to suspect something more complex is going on than just the snippits pasted.These links are both to version 1.22 (not yet released). Going back in time to version 1.21, the file looks like this
https://github.com/dropbox/mypy-protobuf/blob/3cd710c3346eb65c33e64107891299f173e58b82/test/proto/test3_pb2.pyi.expected#L114
Potential hypotheses (guessing based on what might be different):
Mypy version? Our tests (back at 1.21) ran against mypy 0.761 Our tests (on master, soon to be 1.22) run against mypy 0.780
Different mypy flags? Our instantiation (pretty vanilla) https://github.com/dropbox/mypy-protobuf/blob/master/run_test.sh#L40 https://github.com/dropbox/mypy-protobuf/blob/master/mypy.ini
Different test case? Perhaps paste your entire .pyi file as generated here? Dumping your test case into mypy-playground, it appears to pass https://mypy-play.net/?mypy=latest&python=3.8&gist=4002b2b37938f880a515a836af5c7ada
Oooh interesting!! I think mypy version is to blame here. Somewhere between 0.750 https://mypy-play.net/?mypy=0.750&python=3.8&gist=b605afaed49a278a76deed5fbc7f8439 And 0.760 https://mypy-play.net/?mypy=0.760&python=3.8&gist=b605afaed49a278a76deed5fbc7f8439
mypy started accepting these (hit the burger in the top right -> press run to run mypy)
That could be possible. I tried revisiting this issue over the weekend and wasn’t able to reproduce it any more. To be honest, I’m prepared to just let it go. If I figure out how to reproduce it again (by accident because I won’t be dedicating any deliberate effort), then I’ll re-open this issue. Thanks for taking a look.