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

Use Poetry for the Python linter #2042

Merged
merged 8 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/python-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:
- 'master'
paths:
- '**/*.py'
- '.github/workflows/python-lint.yaml'
pull_request:
branches:
- master
- experimental
paths:
- '**/*.py'
- '.github/workflows/python-lint.yaml'

jobs:
run-python-linter:
Expand All @@ -27,13 +29,21 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: false
virtualenvs-path: ~/.venv
installer-parallel: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements.linter.txt
poetry install --with=dev-host

- name: Analyzing the code with flake8
run: |
if [ -n "$(git ls-files '*.py')" ]; then
flake8 $(git ls-files '*.py')
poetry run flake8 $(git ls-files '*.py')
fi
19 changes: 8 additions & 11 deletions docs/developer-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,23 @@ $ act -W .github/workflows/python-lint.yaml
The command above will run the linter on the all the Python files in the repository. If you want to run the linter
on a specific file, you can try the commands in the next section.

### Running the linter using `venv`
### Running the linter using Poetry

First, create a virtual environment and install the dependencies:
You have to install Poetry first. You can find the installation instructions
[here](https://python-poetry.org/docs/#installing-with-the-official-installer).

```bash
$ python3 -m venv venv/
$ source venv/bin/activate
$ pip install -r requirements/requirements.linter.txt
```

To run the linter on all the Python files in the repository, run the following command:
After installing Poetry, run the following commands:

```bash
$ flake8 $(git ls-files '**/*.py')
# Install the dependencies
$ poetry install --with=dev-host
$ poetry run flake8 $(git ls-files '**/*.py')
```

To run the linter on a specific file, run the following command:

```bash
$ flake8 path/to/file.py
$ poetry run flake8 path/to/file.py
```


Expand Down
55 changes: 55 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.poetry]
name = "anthias"
version = "0.18.8"
description = "The world's most popular open source digital signage project."
readme = "README.md"
package-mode = false

[tool.poetry.dependencies]
python = ">=3.8,<3.12"

[tool.poetry.group.dev-host.dependencies]
flake8 = "^5.0.4"

[tool.poetry.scripts]
wee = "ls -l"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
1 change: 0 additions & 1 deletion requirements/requirements.linter.txt

This file was deleted.

Loading