Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit f77bb1b7 authored by Dorian Turba's avatar Dorian Turba
Browse files

flake8 job

parent 09a3482b
No related branches found
No related tags found
No related merge requests found
files:
template: ./python/code_quality/flake8/flake8.yml
documentation: ./python/code_quality/flake8/README.md
data:
description: "Run flake8 on your repository"
icon: 💎
public: true
labels:
- Lint
- Utilities
- Code Quality
- Python
license: MIT
deprecated: false
## Objective
Run [Flake8](https://flake8.pycqa.org/en/latest/) on your Python code to ensure it adheres to PEP8
standards and to detect various errors such as syntax errors, semantic errors, and complex code.
Flake8 is a Python tool that glues together pycodestyle, pyflakes, and McCabe.
### Global Configuration of Flake8
To add configuration to `flake8` shared with any other usage of flake8 (such as manual run,
pre-commit, etc), you can use `.flake8` configuration file. Learn more
about [flake8 configuration](https://flake8.pycqa.org/en/latest/user/configuration.html) files.
See this example:
```ini
[flake8]
exclude = .git,__pycache__,venv,dist
max-complexity = 10
max-line-length = 100
```
This example ignores certain errors, sets the maximum line length to 100 characters, excludes the
tests directory, and sets the maximum McCabe complexity to 10.
## How to use it
1. Configure the `.flake8` file in your repository's root directory with your desired rules.
2. Include the flake8 template in your CI/CD configuration (see quick use above).
3. Customize the template if it's relevant.
## Add a <a href="https://flake8.pycqa.org/"><img alt="Code style: Flake8" src="https://img.shields.io/badge/Flake8-checks-blue"></a> Badge to your project README.md
To display the use of Flake8 in your project, you can add the following badge to your README.md:
```markdown
<a href="https://flake8.pycqa.org/">
<img alt="Code style: Flake8" src="https://img.shields.io/badge/Flake8-checks-blue">
</a>
```
flake8:
image: python:latest
stage: code_quality
script:
- python --version # Debug
- python -m venv venv --upgrade-deps || python -m venv venv # upgrade-deps is not supported before 3.9
- source venv/bin/activate
- pip install flake8
- flake8
only:
changes:
- ./**/*.py
- .gitlab-ci.yml
- pyproject.toml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment