From d87ff44a086d56210a1366fc40232f65b6af9445 Mon Sep 17 00:00:00 2001 From: lucaskampi Date: Thu, 9 Apr 2026 16:19:48 -0300 Subject: [PATCH] Migrate from pip to poetry for dependency management --- .github/workflows/ci.yml | 13 +++++----- .gitignore | 4 ++- README.md | 2 +- pyproject.toml | 53 ++++++++++++++++++++++++++++++++++++++++ requirements.txt | 21 ---------------- 5 files changed, 64 insertions(+), 29 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12b8649..c7e8a50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,15 +22,16 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install Poetry run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - pip install pytest pytest-django pytest-cov + curl -sSL https://install.python-poetry.org | python3 - + poetry --version + + - name: Install dependencies + run: poetry install - name: Run tests and collect coverage - run: | - pytest --maxfail=1 --disable-warnings -q --cov=entities --cov-report=xml:coverage.xml --cov-report=html:coverage_html + run: poetry run pytest --maxfail=1 --disable-warnings -q --cov=entities --cov-report=xml:coverage.xml --cov-report=html:coverage_html - name: Upload coverage artifacts uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index cd82b29..d56498b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.venv +/poetry.lock /inventory_api/__pycache__/ /tests/__pycache__/ *.pyc @@ -6,4 +7,5 @@ .env db.sqlite3 .coverage -coverage.xml \ No newline at end of file +coverage.xml +coverage_html/ \ No newline at end of file diff --git a/README.md b/README.md index 0ffae92..8cf5ebb 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ source .venv/bin/activate ### 2. Install dependencies ```bash -pip install -r requirements.txt +poetry install ``` ### 3. Apply migrations diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4b95bbb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,53 @@ +[tool.poetry] +name = "inventory-api" +version = "0.1.0" +description = "A simple RESTful API for managing Entity records, built with Django and Django Ninja" +authors = ["Your Name "] +readme = "README.md" +packages = [{include = "inventory_api"}, {include = "entities"}] + +[tool.poetry.dependencies] +python = "^3.11" +Django = "^6.0.1" +django-ninja = "^1.5.3" +django-cors-headers = "^4.0.0" +pydantic = "^2.12.5" +uvicorn = "^0.40.0" +asgiref = "^3.11.0" +h11 = "^0.16.0" +click = "^8.3.1" +sqlparse = "^0.5.5" +typing-extensions = "^4.15.0" +annotated-types = "^0.7.0" +pydantic-core = "^2.41.5" + +[tool.poetry.group.dev.dependencies] +pytest = "^9.0.2" +pytest-django = "^4.11.1" +pytest-cov = "^7.0.0" +coverage = "^7.13.1" +typing-inspection = "^0.4.2" +Pygments = "^2.19.2" +iniconfig = "^2.3.0" +packaging = "^25.0" +pluggy = "^1.6.0" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.pytest.ini_options] +DJANGO_SETTINGS_MODULE = "inventory_api.settings" +testpaths = ["tests"] +python_files = ["tests.py", "test_*.py", "*_tests.py"] + +[tool.coverage.run] +source = ["entities"] +branch = true + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise NotImplementedError", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 8993b3f..0000000 --- a/requirements.txt +++ /dev/null @@ -1,21 +0,0 @@ -annotated-types==0.7.0 -asgiref==3.11.0 -click==8.3.1 -coverage==7.13.1 -Django==6.0.1 -django-ninja==1.5.3 -h11==0.16.0 -iniconfig==2.3.0 -packaging==25.0 -pluggy==1.6.0 -pydantic==2.12.5 -pydantic_core==2.41.5 -Pygments==2.19.2 -pytest==9.0.2 -pytest-cov==7.0.0 -pytest-django==4.11.1 -sqlparse==0.5.5 -typing-inspection==0.4.2 -typing_extensions==4.15.0 -uvicorn==0.40.0 -django-cors-headers