-
-
Save jbwhit/eecdd1cac2756df85ad165f437445b0b to your computer and use it in GitHub Desktop.
I am very happy with your config that can also reflect ruff configs written in pyproject.toml such as:
[tool.ruff.format]
quote-style = "single"If you guys also want it to run check before format, then use this:
@handle_line_ending_and_magic
def format_code(
self, code: str, notebook: bool, args: List[str] = [], **options
) -> str:
# Lint
linting = subprocess.run(
[self.ruff_bin, "check", "--fix", "--exit-zero", "-"],
input=code,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
encoding="utf-8",
)
# Format
linted_code = linting.stdout
process = subprocess.run(
[self.ruff_bin, "format", "-"],
input=linted_code,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
encoding="utf-8",
)
if process.stderr:
logger.info(process.stderr)
return code
else:
return process.stdoutI followed steps from YT vid, still could not get
Formatter_iconwork w/ruff_formatin activeJupyter notebook. I have installed python 3.10<= usingvenv. I likedkeyboard shortcutwhich also doesn't work ss attached below. Any help appreciated. Discord: JordanTheDodger
Update: I finally figured out the error. I am elated to capture my first error with new kid on the block RUFFFFF :100 Kudos @jbwhit
I followed steps from YT vid, still could not get
Formatter_iconwork w/ruff_formatin activeJupyter notebook. I have installed python 3.10<= usingvenv. I likedkeyboard shortcutwhich also doesn't work ss attached below. Any help appreciated. Discord: JordanTheDodgerUpdate: I finally figured out the error. I am elated to capture my first error with new kid on the block RUFFFFF :100 Kudos @jbwhit
Was the error on from this document or something on your side?
I configured virtual env using conda. For some reason, ruff configuration didn't register. I had to shutdown Jupyter and virtual env. Technically not a "true" error just operational hiccup. 👍

❤️