Jupyter4Science / jupyterlab-ide

JupyterLab + tab completion + debugger + linter = Fully-fleged IDE
MIT License
3 stars 0 forks source link

Code Formatter tutorial notebooks #58

Open Dcosthephalump opened 1 year ago

Dcosthephalump commented 1 year ago

For the code formatter extension, this issue details the process for creating a code formatter notebook. Because there are several different code formatters that are compatible with Python, this tutorial will stick with Python formatters. Future work could add tutorials on formatters for other languages. Knowing that, the strategy for this is:

Ideally, the example notebooks from this could be used to create material for #43 and solve much of nbdime here.

Dcosthephalump commented 1 year ago

I was trying to figure out a problem with my installation of the black code formatter. It was not following through with the promised output from:

in:

def foo():

print("All the newlines above me should be deleted!")

if condition:

print("No newline above me!")

print("There is a newline above me, and that's OK!")

class Point:

x: int
y: int

out:

def foo(): print("All the newlines above me should be deleted!")

if condition: print("No newline above me!")

print("There is a newline above me, and that's OK!")

class Point: x: int y: int

It turns out, this is for version 23.3.0 of black. I had installed the blue code formatter as version 0.9.1, which relied on version 22.1.0 of black. This broke the expected output.

Dcosthephalump commented 1 year ago

CodeFormatter has to be installed with the pip package manager. The same is true for the code formatters