- 
                Notifications
    
You must be signed in to change notification settings  - Fork 22
 
Install black/ruff if not found in current python environment CF-495 #16
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
Conversation
| formatter_cmds.append("black $file") | ||
| print("checking if black exists") | ||
| try: | ||
| import black | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should do this checking exactly the same way we run black when we do the formatting. I believe it runs as a subprocess. We should detect with that method if black is installed. The same goes for ruff formatter
| import black | ||
| except ImportError as e: | ||
| print("black not found, installing via pip") | ||
| subprocess.run(["pip", "install", "black"]) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not modify the user environment like this, only recommend the user to install black with this command. same for ruff
| 
               | 
          ||
| Licensor: CodeFlash Inc. | ||
| Licensed Work: Codeflash Client version 0.9.x | ||
| Licensed Work: Codeflash Client version 0.0.x | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also this file should be reverted
| # These version placeholders will be replaced by poetry-dynamic-versioning during `poetry build`. | ||
| __version__ = "0.9.2" | ||
| __version_tuple__ = (0, 9, 2) | ||
| __version__ = "0.0.0.post2491.dev0+2f81f2ca" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file should also be reverted.
Added a try/except block which tries to import the formatter, it calls
pip installviasubprocessif the import fails.