Enhancement: Python Script Editor - Flake8 preferences, iSort, Black

Description:
The Python script editor is a huge and welcome improvement over the prior node (thanks :clap: :clap: :clap:).

It appears as if the editor is using flake8 to check compliance with code conventions (good), however, there is no way to vary the defaults (not so good). For instance flake8 default line length is 80 characters, whereas Black defaults to 88 (which is more practical). There is no facility to switch off flake8 warnings which may prove irritating if they are not relevant to the code (e.g. type annotations - though I haven’t tested this yet).

Whilst it is good to have linting of the code, it would be extra nice if we could also have automatic code formatting, such as Black and iSort. This could be implemented as a button (“Autoformat Code”) which would improve readability by wrapping lines within the bounds of a reasonably sized script editor window (88 character width).

Finally, you may want to consider ruff instead of flake8. It won’t make much difference as the script is short, but ruff is flake8 written in Rust and, therefore, significantly quicker.

Steps to reproduce:

  1. Open Python Script editor
  2. Enter text

Actual results:
Highlighting of script to indicate word wrap at 80 characters. Highlighting of code convention violations.

Expected results:
Control over linter configuration (ruff, flake8)

Auto-format code (black, iSort)

Attachments:
N/A

OS:
N/A

2 Likes

+1
I agree, it seems a reasonable choice in nowsdays

Thank you @DiaAzul, @HaveF for the suggestion.

I have opened a ticket for this feature request: AP-21569

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.