Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Feature Request]: Auto-format using custom or specific rules only #21355

Open
bevoorrading opened this issue Sep 20, 2023 · 3 comments
Open

Comments

@bevoorrading
Copy link

Would it be possible to have the option to have an auto-format option with a custom set of rules, or where you specify the specific rules yourself?

I don't like to/can't use the auto-format with full PEP-8 style or so, but I would love to have some simple things be automatically corrected on saving, like trailing whitespaces (W291) or blank lines containing whitespace (W293). These are small things that sneak in so easily, and are a waste of time to correct manually.

It could be made just like "Ingore following errors and warnings"-box, except you specify the warnings/errors you want to be corrected.

@ccordoba12
Copy link
Member

ccordoba12 commented Sep 21, 2023

Hey @bevoorrading, thanks for reporting. You said:

Would it be possible to have the option to have an auto-format option with a custom set of rules, or where you specify the specific rules yourself?

From our current auto-formatters, Black doesn't offer that possibility but Autopep8 does. However, that would require two things: designing the graphical interface to set those options on the Spyder side and adding support for them on python-lsp-server (the backend we use for auto-formatting, code completion and linting).

Unfortunately, we don't have time to this at the moment. So, the initiative to implement this feature would need to come from our community.

but I would love to have some simple things be automatically corrected on saving, like trailing whitespaces (W291) or blank lines containing whitespace (W293). These are small things that sneak in so easily, and are a waste of time to correct manually.

There's already an option to automatically do that:

imagen

Let us know if it works for you.

@bevoorrading
Copy link
Author

Oh, cool. I wasn't aware of this option. Yes, that helps very much.

There are perhaps a few other warnings I'd like to include, but they're much, much less frequent and much easier to change (or just by getting used to writing it properly). So the stripping whitespace option mostly solves the problem for me, to the point where implementing something new wouldn't be worth it at all, certainly if I'm the only one interested.

Thanks.

PS: one question, do the option you marked and the one 3 lines up do the same with the only exception of when saving vs immediately?

@ccordoba12
Copy link
Member

So the stripping whitespace option mostly solves the problem for me

Great!

to the point where implementing something new wouldn't be worth it at all, certainly if I'm the only one interested.

We'll leave the issue open in case other people think this is worth the effort.

PS: one question, do the option you marked and the one 3 lines up do the same with the only exception of when saving vs immediately?

Right, and I forgot about it because I don't use it myself. I only want to remove white spaces for the new the code that I'm adding to the file, not for the one that's already present in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants