Skip to content

Commit

Permalink
Migrate to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
yalef committed Dec 1, 2023
1 parent a3aa8ce commit 5bfcead
Show file tree
Hide file tree
Showing 22 changed files with 3,068 additions and 618 deletions.
35 changes: 28 additions & 7 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
fail-fast: false
matrix:
python-version:
- '3.9'
- '3.10'
- '3.11'
django-version:
Expand All @@ -37,20 +36,42 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Cache poetry dependencies
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install local dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction

- name: Install Django
run: |
pip install --upgrade pip wheel setuptools
pip install --requirement requirements/local_build.txt
pip install 'django${{ matrix.django-version }}'
poetry run pip install 'django${{ matrix.django-version }}'
- name: Prepare env
run: |
inv ci.prepare
poetry run inv ci.prepare
- name: Run checks ${{ matrix.python-version }}
run: inv git.run-hooks
run: poetry run inv pre-commit.run-hooks

- name: Upload results to coveralls
run: |
pip install coveralls
coveralls --service=github
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
48 changes: 41 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@ repos:
- id: isort
name: isort (python)

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
exclude: node_modules|migrations|scripts|.venv|__init__.py
additional_dependencies: [
# A flake8 plugin that checks django code style.
# https://github.com/rocioar/flake8-django
flake8-django,
# required by flake8-django
django,
django_extensions,
# A plugin for Flake8 finding likely bugs and design problems in your program.
# https://github.com/PyCQA/flake8-bugbear
flake8-bugbear,
# A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
# https://github.com/m-burst/flake8-pytest-style
flake8-pytest-style,
# A flake8 plugin that warn about backslashes usage.
# https://github.com/wemake-services/flake8-broken-line
flake8-broken-line,
# A simple module that adds an extension for the fantastic pydocstyle tool to flake8.
# https://github.com/PyCQA/flake8-docstrings
flake8-docstrings,
# McCabe complexity checker.
# https://github.com/PyCQA/mccabe
mccabe,
# A flake8 plug-in loading the configuration from pyproject.toml
flake8-pyproject,
]

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.4.0
hooks:
Expand Down Expand Up @@ -44,20 +75,23 @@ repos:
types: [ file ]
stages: [ push ]

- id: linters
name: run linters
entry: inv linters.all
- id: tests
name: run tests
entry:
inv python.run
" -m coverage run --source import_export_extensions
--omit import_export_extensions/migrations -m pytest -v"
language: system
pass_filenames: false
types: [ python ]
stages: [ push ]

- id: tests
name: run tests
entry: inv tests.run-ci
- id: mypy
name: mypy
entry: inv mypy.run
language: system
pass_filenames: false
types: [ python ]
types: [ file ]
stages: [ push ]

- id: package_installation_verify
Expand Down
16 changes: 12 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
# Job for install dependencies with poetry
# Docs: https://docs.readthedocs.io/en/stable/build-customization.html#install-dependencies-with-poetry
post_create_environment:
# https://python-poetry.org/docs/#installing-manually
- pip install -U poetry
# Tell poetry to not use a virtual environment
- poetry config virtualenvs.create false
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
- poetry install --with docs

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

python:
install:
- requirements: requirements/development.txt
11 changes: 4 additions & 7 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ Ready to contribute? Here's how to set up `django-import-export-extensions` for
3. Setup virtual environment using pyenv::

$ pyenv install 3.11
$ pyenv virtualenv 3.11 django-import-export-extensions
$ pyenv local django-import-export-extensions
$ pyenv activate django-import-export-extensions
$ pip install -r requirements/local_build.txt
$ inv project.init
$ pyenv shell $(pyenv latest 3.11)
$ poetry config virtualenvs.in-project true
$ poetry env use $(which python) && poetry install && source .venv/bin/activate

4. Create a branch for local development::

Expand All @@ -82,8 +80,7 @@ Ready to contribute? Here's how to set up `django-import-export-extensions` for
5. When you're done making changes, check that your changes pass flake8 and the
tests::

$ inv tests.run
$ inv linters.all
$ inv pre-commit.run-hooks

6. Commit your changes and push your branch to GitHub::

Expand Down
2 changes: 1 addition & 1 deletion import_export_extensions/admin/mixins/export_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ def celery_export_action(self, request, *args, **kwargs):
resources=self.get_export_resource_classes(),
)
resource_kwargs = self.get_export_resource_kwargs(
request=request,
*args,
**kwargs,
request=request,
)
if request.method == "POST" and form.is_valid():
file_format = formats[int(form.cleaned_data["file_format"])]
Expand Down
2 changes: 1 addition & 1 deletion import_export_extensions/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ def export(
queryset=queryset,
)
return super().export( # type: ignore
queryset=queryset,
*args,
**kwargs,
queryset=queryset,
)

def export_resource(self, obj):
Expand Down
Loading

0 comments on commit 5bfcead

Please sign in to comment.