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

Generated .pyi files include __pycache__, are not idempotent #477

Closed
lidavidm opened this issue Jun 22, 2022 · 4 comments · Fixed by #480
Closed

Generated .pyi files include __pycache__, are not idempotent #477

lidavidm opened this issue Jun 22, 2022 · 4 comments · Fixed by #480

Comments

@lidavidm
Copy link

I've noticed a few things about generated .pyi files:

  • __pycache__ gets picked up and imported,
  • Entries are not sorted (though this isn't really a big deal, it kinda helps with reviewing the diff)
  • Entries get duplicated if run multiple times/generation is not idempotent

The last one is probably harder to solve since it appears Protoletariat is not assuming it has full control of the pyi (understandable), or else it could overwrite instead of append.

@cpcloud
Copy link
Owner

cpcloud commented Jun 22, 2022

Sweet, thanks for the issue. I think we can probably address all three.

The last one may be a bit tricky as you say.

Maybe inserting a comment at the end like # __protol__: $ORIGINAL_IMPORT to indicate that the line came from protol and then leaving out duplicates during rewriting would work.

@lidavidm
Copy link
Author

Frankly a simple string match is probably enough, if janky

@cpcloud
Copy link
Owner

cpcloud commented Jun 22, 2022

@lidavidm Do you have a concrete example of

__pycache__ gets picked up and imported,

I'm not seeing .pyi files inside of __pycache__ anywhere.

@lidavidm
Copy link
Author

lidavidm commented Jun 22, 2022

Oh sorry, what I mean is it'll generate things like

from . import __pycache__

inside the .pyi files if not run from a clean checkout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants