jupyterlab_code_formatter
jupyterlab_code_formatter copied to clipboard
respect options in setup.cfg?
Checklist prior to opening an issue
- [x] I have followed fully the installation steps laid out in the documentation site.
- [x] I have restarted jupyterlab.
- [x] I have read the FAQ section in the documentation site.
Describe the bug It is usual to have per-project settings, e.g. in a setup.cfg file. In my brief tests these do not seem to be respected by e.g. isort executed via jupyterlab_code_foramatter - is there a way to make the formatters to respect these settings?
Diagnostic commands Please attach the output of the following commands (please format them properly)
conda list
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 1_gnu conda-forge
alembic 1.4.2 pyh9f0ad1d_0 conda-forge
appdirs 1.4.3 py_1 conda-forge
argon2-cffi 20.1.0 py38h1e0a361_1 conda-forge
async_generator 1.10 py_0 conda-forge
asyncssh 2.3.0 py_0 conda-forge
attrs 20.1.0 pyh9f0ad1d_0 conda-forge
backcall 0.2.0 pyh9f0ad1d_0 conda-forge
backports 1.0 py_2 conda-forge
backports.functools_lru_cache 1.6.1 py_0 conda-forge
bcrypt 3.2.0 py38h1e0a361_0 conda-forge
black 19.10b0 py_4 conda-forge
bleach 3.1.5 pyh9f0ad1d_0 conda-forge
blinker 1.4 py_1 conda-forge
brotlipy 0.7.0 py38h1e0a361_1000 conda-forge
c-ares 1.16.1 h516909a_3 conda-forge
ca-certificates 2020.6.20 hecda079_0 conda-forge
certifi 2020.6.20 py38h32f6830_0 conda-forge
certipy 0.1.3 py_0 conda-forge
cffi 1.14.1 py38h5bae8af_0 conda-forge
chardet 3.0.4 py38h32f6830_1006 conda-forge
click 7.1.2 pyh9f0ad1d_0 conda-forge
configurable-http-proxy 4.2.1 node13_he01fd0c_0 conda-forge
cryptography 3.0 py38h766eaa4_0 conda-forge
dbus 1.13.6 he372182_0 conda-forge
decorator 4.4.2 py_0 conda-forge
defusedxml 0.6.0 py_0 conda-forge
entrypoints 0.3 py38h32f6830_1001 conda-forge
expat 2.2.9 he1b5a44_2 conda-forge
fontconfig 2.13.1 h86ecdb6_1001 conda-forge
freetype 2.10.2 he06d7ca_0 conda-forge
gettext 0.19.8.1 hc5be6a0_1002 conda-forge
glib 2.65.0 h6f030ca_0 conda-forge
gst-plugins-base 1.14.5 h0935bb2_2 conda-forge
gstreamer 1.14.5 h36ae1b5_2 conda-forge
icu 64.2 he1b5a44_1 conda-forge
idna 2.10 pyh9f0ad1d_0 conda-forge
importlib-metadata 1.7.0 py38h32f6830_0 conda-forge
importlib_metadata 1.7.0 0 conda-forge
ipykernel 5.3.4 py38h23f93f0_0 conda-forge
ipython 7.17.0 py38h1cdfbd6_0 conda-forge
ipython_genutils 0.2.0 py_1 conda-forge
ipywidgets 7.5.1 py_0 conda-forge
isort 5.4.2 py38h32f6830_0 conda-forge
jedi 0.17.2 py38h32f6830_0 conda-forge
jinja2 2.11.2 pyh9f0ad1d_0 conda-forge
jpeg 9d h516909a_0 conda-forge
json5 0.9.4 pyh9f0ad1d_0 conda-forge
jsonschema 3.2.0 py38h32f6830_1 conda-forge
jupyter 1.0.0 py_2 conda-forge
jupyter_client 6.1.6 py_0 conda-forge
jupyter_console 6.1.0 py_1 conda-forge
jupyter_core 4.6.3 py38h32f6830_1 conda-forge
jupyter_telemetry 0.0.5 py_0 conda-forge
jupyterhub 1.1.0 py38h32f6830_4 conda-forge
jupyterhub-base 1.1.0 py38h32f6830_4 conda-forge
jupyterhub-systemdspawner 0.13 pypi_0 pypi
jupyterlab 2.2.6 py_0 conda-forge
jupyterlab_code_formatter 1.3.6 py_0 conda-forge
jupyterlab_server 1.2.0 py_0 conda-forge
krb5 1.17.1 hfafb76e_2 conda-forge
ld_impl_linux-64 2.34 hc38a660_9 conda-forge
libclang 9.0.1 default_hde54327_0 conda-forge
libcurl 7.71.1 hcdd3856_5 conda-forge
libedit 3.1.20191231 he28a2e2_2 conda-forge
libev 4.33 h516909a_0 conda-forge
libffi 3.2.1 he1b5a44_1007 conda-forge
libgcc-ng 9.3.0 h24d8f2e_16 conda-forge
libgomp 9.3.0 h24d8f2e_16 conda-forge
libiconv 1.16 h516909a_0 conda-forge
libllvm9 9.0.1 he513fc3_1 conda-forge
libnghttp2 1.41.0 h8cfc5f6_2 conda-forge
libpng 1.6.37 hed695b0_2 conda-forge
libsodium 1.0.18 h516909a_0 conda-forge
libssh2 1.9.0 hab1572f_5 conda-forge
libstdcxx-ng 9.3.0 hdf63c60_16 conda-forge
libuuid 2.32.1 h14c3975_1000 conda-forge
libuv 1.34.0 h516909a_0 conda-forge
libxcb 1.13 h14c3975_1002 conda-forge
libxkbcommon 0.10.0 he1b5a44_0 conda-forge
libxml2 2.9.10 hee79883_0 conda-forge
mako 1.1.3 pyh9f0ad1d_0 conda-forge
markupsafe 1.1.1 py38h1e0a361_1 conda-forge
mistune 0.8.4 py38h1e0a361_1001 conda-forge
nb_conda_kernels 2.2.4 py38h32f6830_0 conda-forge
nbconvert 5.6.1 py38h32f6830_1 conda-forge
nbformat 5.0.7 py_0 conda-forge
ncurses 6.2 he1b5a44_1 conda-forge
nodejs 13.13.0 hf5d1a2b_0 conda-forge
notebook 6.1.3 py38h32f6830_0 conda-forge
nspr 4.28 he1b5a44_0 conda-forge
nss 3.56 he751ad9_0 conda-forge
oauthlib 3.0.1 py_0 conda-forge
openssl 1.1.1g h516909a_1 conda-forge
packaging 20.4 pyh9f0ad1d_0 conda-forge
pamela 1.0.0 py_0 conda-forge
pandoc 2.10.1 h516909a_0 conda-forge
pandocfilters 1.4.2 py_1 conda-forge
paramiko 2.7.1 pyh9f0ad1d_1 conda-forge
parso 0.7.0 pyh9f0ad1d_0 conda-forge
pathspec 0.8.0 pyh9f0ad1d_0 conda-forge
pcre 8.44 he1b5a44_0 conda-forge
pexpect 4.8.0 py38h32f6830_1 conda-forge
pickleshare 0.7.5 py38h32f6830_1001 conda-forge
pip 20.2.2 py_0 conda-forge
prometheus_client 0.8.0 pyh9f0ad1d_0 conda-forge
prompt-toolkit 3.0.6 py_0 conda-forge
prompt_toolkit 3.0.6 0 conda-forge
pthread-stubs 0.4 h14c3975_1001 conda-forge
ptyprocess 0.6.0 py_1001 conda-forge
pycparser 2.20 pyh9f0ad1d_2 conda-forge
pycurl 7.43.0.5 py38h4400d41_2 conda-forge
pygments 2.6.1 py_0 conda-forge
pyjwt 1.7.1 py_0 conda-forge
pynacl 1.3.0 py38h516909a_1001 conda-forge
pyopenssl 19.1.0 py_1 conda-forge
pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge
pyqt 5.12.3 py38ha8c2ead_3 conda-forge
pyrsistent 0.16.0 py38h1e0a361_0 conda-forge
pysocks 1.7.1 py38h32f6830_1 conda-forge
python 3.8.5 h1103e12_5_cpython conda-forge
python-dateutil 2.8.1 py_0 conda-forge
python-editor 1.0.4 py_0 conda-forge
python-json-logger 0.1.11 py_0 conda-forge
python_abi 3.8 1_cp38 conda-forge
pyzmq 19.0.2 py38ha71036d_0 conda-forge
qt 5.12.5 hd8c4c69_1 conda-forge
qtconsole 4.7.6 pyh9f0ad1d_0 conda-forge
qtpy 1.9.0 py_0 conda-forge
readline 8.0 he28a2e2_2 conda-forge
regex 2020.7.14 py38h1e0a361_0 conda-forge
remotespawner 0.0.1.dev0 dev_0 <develop>
requests 2.24.0 pyh9f0ad1d_0 conda-forge
ruamel.yaml 0.16.10 py38h1e0a361_0 conda-forge
ruamel.yaml.clib 0.2.0 py38h1e0a361_1 conda-forge
send2trash 1.5.0 py_0 conda-forge
setuptools 49.6.0 py38h32f6830_0 conda-forge
six 1.15.0 pyh9f0ad1d_0 conda-forge
sqlalchemy 1.3.19 py38h1e0a361_0 conda-forge
sqlite 3.33.0 h4cf870e_0 conda-forge
sshspawner 0.0.1 dev_0 <develop>
terminado 0.8.3 py38h32f6830_1 conda-forge
testpath 0.4.4 py_0 conda-forge
tk 8.6.10 hed695b0_0 conda-forge
toml 0.10.1 pyh9f0ad1d_0 conda-forge
tornado 6.0.4 py38h1e0a361_1 conda-forge
traitlets 4.3.3 py38h32f6830_1 conda-forge
typed-ast 1.4.1 py38h516909a_0 conda-forge
urllib3 1.25.10 py_0 conda-forge
wcwidth 0.2.5 pyh9f0ad1d_1 conda-forge
webencodings 0.5.1 py_1 conda-forge
wheel 0.35.1 pyh9f0ad1d_0 conda-forge
widgetsnbextension 3.5.1 py38h32f6830_1 conda-forge
xorg-libxau 1.0.9 h14c3975_0 conda-forge
xorg-libxdmcp 1.1.3 h516909a_0 conda-forge
xz 5.2.5 h516909a_1 conda-forge
zeromq 4.3.2 he1b5a44_3 conda-forge
zipp 3.1.0 py_0 conda-forge
zlib 1.2.11 h516909a_1007 conda-forge
jupyter labextension list
JupyterLab v2.2.6
Known labextensions:
app dir: /net/exo/landclim/mathause/.conda/envs/jupyterhub_test/share/jupyter/lab
@ryantam626/jupyterlab_code_formatter v1.3.6 enabled OK
jupyter serverextension list
config dir: /home/mathause/.jupyter
jupyterlab_code_formatter enabled
- Validating...
jupyterlab_code_formatter OK
config dir: /net/exo/landclim/mathause/.conda/envs/jupyterhub_test/etc/jupyter
jupyterlab enabled
- Validating...
jupyterlab 2.2.6 OK
config dir: /etc/jupyter
ipyparallel.nbextension enabled
- Validating...
Error loading server extension ipyparallel.nbextension
X is ipyparallel.nbextension importable?
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Hi! Sorry for the delay in replying, this plugin indeed does not respect setup.cfg.
To make it respect it requires a bit more thought, if you are using jupyter lab for only a single project then sure it's easy, but I assume most people use jupyter lab in more than one project.
In the meantime, you might wanna try using the config system already implemented (though it's a bit limited) - this link should help.
Respecting the file-based configuration files like setup.cfg and pyproject.toml would be useful for:
- When collaborating with other people, it's typical to commit those configuration files to the repository. That way everyone applies the same autoformatting configurations.
- It may be the case that a user would want different settings for different projects (especially if some of those projects involve collaborating with other people). Based on my understanding, the settings right now are globally applied at the user level.
I agree with @jayqi, this plugin should respect the standard config files like pyproject.toml otherwise it will deliver inconsistent results with the other tools like underlying tools themselves, with nbqa or whatever.
The formatter should use the configuration options that apply in the directory that the notebook is saved in, regardless of whether they are different projects or the same. This is the same behaviour as the underlying tools, like black and isort.
Is this in the roadmap to be fixed?
I have line-length = 125 under [tools.black] in pyproject.toml. It's frustrating that this is ignored by "Apply Black Formatter".
Sorry for the late reply people, I haven't given this project much love, I just kinda lost steam over the years as I got increasingly burnt out, but lately I have gotten a second wind (perhaps only for a brief period...)
FWIW I am in middle to a big refactor for the project (mostly due to the evolution of jupyterlab's plugin tooling), this would be one of the things I can look at after that.
Without the the refactor, the development envrionment for this plugin is just nightmare-ish to use, so that is currently trumping all tasks.