Skip to content

Enhance code style checking #261

@jorgepiloto

Description

@jorgepiloto

🐞 Problem

At the moment, only flake8 are being used for checking the code style. Although very useful, this tool does not cover things such us proper import order or code formatting.

Therefore, it is usual to use flake8 together with black and isort:

  • black is the uncompromising Python code formatter.
  • isort makes your imports compliant with PEP-8.

Both tools are very popular in the Python ecosystem. Other projects in the PyAnsys ecosystem such us PyMAPDL also benefit from previous code style tools.

Code quality can also be improved by checking docstrings or misspelled words. For this task, other tools can be used:

💡 Solution

From my point of view, the best way to implement the code style checking is using pre-commit. This has the following advantages:

  • If you install it locally, it will force you to commit code which follows the code style of the project.
  • It can executed in the CI pipelines, simplifying those as all the logic is stored in a .pre-commit-config.yml file.
  • It is already being used in PyMAPDL. This guarantees uniform code style across projects in the PyAnsys ecosystem.

You can always add more style checking utilities on top of previous ones if those are needed at some point.

Metadata

Metadata

Assignees

Labels

enhancementImprove any current implemented feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions