Skip to content

Conversation

@aseembits93
Copy link
Contributor

Added a try/except block which tries to import the formatter, it calls pip install via subprocess if the import fails.

@aseembits93 aseembits93 changed the title Install black/ruff if not found in current python environment Install black/ruff if not found in current python environment CF-495 Feb 17, 2025
formatter_cmds.append("black $file")
print("checking if black exists")
try:
import black
Copy link
Contributor

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"])
Copy link
Contributor

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
Copy link
Contributor

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"
Copy link
Contributor

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.

@aseembits93 aseembits93 deleted the cf-495 branch April 23, 2025 19:34
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.

3 participants