Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Configure code_prettify extension to load custom yapf styles by default. #1376

Merged
merged 2 commits into from
Jan 1, 2019

Conversation

artificialsoph
Copy link
Contributor

Use case: I use a custom yapf style in my projects and I would like to configure the code_prettify extension to load that custom style.

Currently, this can be done by modifying this extension's configuration, which works fine for individual modification. However, I think more sensible behavior is for the code_prettify extension to by default follow the same behavior described in yapf

YAPF will search for the formatting style in the following manner:

  1. Specified on the command line
  2. In the [style] section of a .style.yapf file in either the current directory or one of its parent directories.
  3. In the [yapf] section of a setup.cfg file in either the current directory or one of its parent directories.
  4. In the ~/.config/yapf/style file in your home directory.

If none of those files are found, the default style is used (PEP8).

method: I accomplished this by using yapf's file_resources submodule, which should help ensure that this extension keeps up with any potential future changes from the yapf team.

testing: I've tested out this configuration using the contributing guidelines.

Add lines to `kernel_exec_on_cell` cfg that mimic 
[yapf command line behavior](https://github.com/google/yapf/blob/f672d7b1073c29054cfcc9c32f344c948e8cf1bf/yapf/__init__.py#L142) 
for loading global and local styles.
@juhasch
Copy link
Member

juhasch commented Dec 29, 2018

I don't know much about yapf,but it looks good to me. Could you add a short description on how to load a custom style in the readme ?

@artificialsoph
Copy link
Contributor Author

@juhasch Thanks! Done 😄

@juhasch juhasch merged commit 2422b76 into ipython-contrib:master Jan 1, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants