Skip to content

Commit

Permalink
Merge f1f9c08 into c21f46c
Browse files Browse the repository at this point in the history
  • Loading branch information
yalef committed Dec 5, 2023
2 parents c21f46c + f1f9c08 commit 21f2e10
Show file tree
Hide file tree
Showing 27 changed files with 3,131 additions and 657 deletions.
39 changes: 30 additions & 9 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
poetry run pip install coveralls
poetry run coveralls --service=github
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
45 changes: 38 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,20 @@ repos:
types: [ file ]
stages: [ push ]

- id: linters
name: run linters
entry: inv linters.all
- id: tests
name: run tests
entry: inv ci.coverage
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: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ History

UNRELEASED
------------------
* Drop support of python 3.9
* Migrate from pip-tools to poetry
* Add base model for ``ImportJob`` and ``ExportJob``
* Extend import results template: show validation errors in table
* Add force-import feature: skip rows with errors while importing
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test: ## run tests quickly with the default Python
pytest

coverage: ## check code coverage quickly with the default Python
coverage run --source import_export_extensions --omit import_export_extensions/migrations -m pytest
coverage run -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html
Expand All @@ -63,10 +63,10 @@ servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: dist ## package and upload a release
twine upload dist/*
poetry publish

dist: clean ## builds source and wheel package
python -m build .
poetry build
ls -l dist

install: clean ## install the package to the active Python's site-packages
Expand Down
5 changes: 4 additions & 1 deletion docs/api_admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Admin
.. automodule:: import_export_extensions.admin.model_admins.mixins
:members:

.. automodule:: import_export_extensions.admin.forms.export_admin_form
.. automodule:: import_export_extensions.admin.forms.export_job_admin_form
:members:

.. automodule:: import_export_extensions.admin.forms.import_job_admin_form
:members:

.. automodule:: import_export_extensions.admin.forms.import_admin_form
Expand Down
16 changes: 0 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@
copyright = "2022-2023, Saritasa"
author = "Saritasa"


# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
try:
from import_export_extensions import __version__

# The short X.Y version.
version = ".".join(__version__.split(".")[:2])
# The full version, including alpha/beta/rc tags.
release = __version__
except ImportError:
version = release = "dev"


# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
Expand Down
5 changes: 0 additions & 5 deletions import_export_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
"""Top-level package for django-import-export-extensions."""

__author__ = """Saritasa"""
__email__ = "pypi@saritasa.com"
__version__ = "0.4.1-alpha"
8 changes: 4 additions & 4 deletions import_export_extensions/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ def clean(
"""
if not value:
return []
return [] # pragma: no cover

# if value is one integer number
value = str(value)

# in some cases if click `enter` values `\n\r` inserted
if self.instance_separator == "\n":
if self.instance_separator == "\n": # pragma: no cover
value = value.replace("\r", "")

raw_instances = utils.clean_sequence_of_string_values(
Expand Down Expand Up @@ -287,7 +287,7 @@ def __init__(self, filename: str):
def render(self, value: Model, *args, **kwargs) -> typing.Optional[str]:
"""Convert DB value to URL to file."""
if not value:
return None
return None # pragma: no cover

if self._get_default_storage() == DEFAULT_SYSTEM_STORAGE:
return f"http://localhost:8000{value.url}"
Expand All @@ -297,7 +297,7 @@ def render(self, value: Model, *args, **kwargs) -> typing.Optional[str]:
def clean(self, value: str, *args, **kwargs) -> typing.Optional[str]:
"""Get the file and check for exists."""
if not value:
return None
return None # pragma: no cover

internal_url = utils.url_to_internal_value(urlparse(value).path)

Expand Down
Loading

0 comments on commit 21f2e10

Please sign in to comment.