From 5106a19129c858f0649560d94f08e0b91d7edb87 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:15:34 +0000 Subject: [PATCH 01/20] [pre-commit.ci] pre-commit autoupdate (#242) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.12.1 → 24.2.0](https://github.com/psf/black/compare/23.12.1...24.2.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 78b3dba..cd4d417 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.2.0 hooks: - id: black args: [--target-version=py38] From 7906f3bf800105e6ab33bfbf44e6863fd178295a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:47:10 +0100 Subject: [PATCH 02/20] [pre-commit.ci] pre-commit autoupdate (#244) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.5.0...v4.6.0) - [github.com/psf/black: 24.2.0 → 24.4.0](https://github.com/psf/black/compare/24.2.0...24.4.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd4d417..b58ac4c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -12,7 +12,7 @@ repos: args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 24.2.0 + rev: 24.4.0 hooks: - id: black args: [--target-version=py38] From cda5b0c3ce38302e7b7f3c4116a1f7634b04dce4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 13:07:41 +0100 Subject: [PATCH 03/20] [pre-commit.ci] pre-commit autoupdate (#245) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.4.0 → 24.4.2](https://github.com/psf/black/compare/24.4.0...24.4.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b58ac4c..6b6d318 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 24.4.0 + rev: 24.4.2 hooks: - id: black args: [--target-version=py38] From 5a91d7a2c7a9afb1bff1080f4ba2039018703c3e Mon Sep 17 00:00:00 2001 From: boxydog <93335439+boxydog@users.noreply.github.com> Date: Tue, 28 May 2024 07:11:20 -0500 Subject: [PATCH 04/20] Update README.rst (#247) Add `postgresql` as an alternative URL, which works and is in the code. --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 2938bcf..23e1773 100644 --- a/README.rst +++ b/README.rst @@ -155,6 +155,7 @@ URL schema | Engine | Django Backend | URL | +======================+===============================================+==================================================+ | PostgreSQL | ``django.db.backends.postgresql`` [1]_ | ``postgres://USER:PASSWORD@HOST:PORT/NAME`` [2]_ | +| | | ``postgresql://USER:PASSWORD@HOST:PORT/NAME`` | +----------------------+-----------------------------------------------+--------------------------------------------------+ | PostGIS | ``django.contrib.gis.db.backends.postgis`` | ``postgis://USER:PASSWORD@HOST:PORT/NAME`` | +----------------------+-----------------------------------------------+--------------------------------------------------+ From 51773f3a89e7e95971f646dc030003d537293439 Mon Sep 17 00:00:00 2001 From: Matt Seymour Date: Tue, 28 May 2024 13:23:37 +0100 Subject: [PATCH 05/20] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a4cd2e4..5d0f474 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ readme = Path("README.rst").read_text() setup( name="dj-database-url", - version="2.1.0", + version="2.2.0", url="https://github.com/jazzband/dj-database-url", license="BSD", author="Original Author: Kenneth Reitz, Maintained by: JazzBand Community", From 3aad9adc71a056e188b1cea0395f2eaad85652e7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:52:48 +0100 Subject: [PATCH 06/20] [pre-commit.ci] pre-commit autoupdate (#249) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/flake8: 7.0.0 → 7.1.0](https://github.com/pycqa/flake8/compare/7.0.0...7.1.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6b6d318..87dcdac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,6 @@ repos: args: [--target-version=py38] - repo: https://github.com/pycqa/flake8 - rev: '7.0.0' + rev: '7.1.0' hooks: - id: flake8 From ed306f37ca04ab75daed9c82e0f117ffa66f16de Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 09:26:28 +0100 Subject: [PATCH 07/20] [pre-commit.ci] pre-commit autoupdate (#251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.4.2 → 24.8.0](https://github.com/psf/black/compare/24.4.2...24.8.0) - [github.com/pycqa/flake8: 7.1.0 → 7.1.1](https://github.com/pycqa/flake8/compare/7.1.0...7.1.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 87dcdac..20d45d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,12 +12,12 @@ repos: args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black args: [--target-version=py38] - repo: https://github.com/pycqa/flake8 - rev: '7.1.0' + rev: '7.1.1' hooks: - id: flake8 From 8d32603e18bfaa777cfe0546a66fd429233a1c85 Mon Sep 17 00:00:00 2001 From: Lino Date: Thu, 3 Oct 2024 05:46:26 +0200 Subject: [PATCH 08/20] Update CHANGELOG.md As requested in https://github.com/jazzband/dj-database-url/issues/250 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 420b764..849403a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +## v2.2.0 (2024-05-28) +* Add disable_server_side_cursors parameter +* Enhance Query String Parsing for Server-Side Binding in Django 4.2 with psycopg 3.1.8+ +* Update django 5.0 python compatability by @mattseymour in #239 +* Improved internals +* Improved documentation + ## v2.1.0 (2023-08-15) * Add value to int parsing when deconstructing url string. From 45ac3bbf89bf1ae9dad13733c30c1d514dfdc3ab Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:33:05 -0500 Subject: [PATCH 09/20] [pre-commit.ci] pre-commit autoupdate (#254) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 20d45d7..dc00db2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace From 99128b507b77532af3fb52b093254546a15ef510 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Thu, 10 Oct 2024 22:45:31 +0100 Subject: [PATCH 10/20] Make config test options not unknown types (#252) * Make config test options not unknown types * Run pyright as part of tests --- .github/workflows/test.yml | 6 ++++-- dj_database_url/__init__.py | 6 +++--- pyproject.toml | 3 +++ requirements.txt | 1 + setup.py | 2 +- tests/test_dj_database_url.py | 2 ++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09fa7ce..30ea045 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,9 +39,10 @@ jobs: pip install -r requirements.txt pip install "Django~=${{ matrix.django-version }}.0" . - - name: Run mypy + - name: Run type checking run: | python -m mypy dj_database_url + python -m pyright dj_database_url - name: Run Tests run: | @@ -52,8 +53,9 @@ jobs: - uses: codecov/codecov-action@v3 - - name: Check mypy types installation + - name: Check types installation run: | pip install . cd tests python -m mypy . + python -m pyright . diff --git a/dj_database_url/__init__.py b/dj_database_url/__init__.py index d620a3d..2bf9d21 100644 --- a/dj_database_url/__init__.py +++ b/dj_database_url/__init__.py @@ -41,7 +41,7 @@ SCHEMES_WITH_SEARCH_PATH = [ # Register database schemes in URLs. for key in SCHEMES.keys(): urlparse.uses_netloc.append(key) -del key +del key # pyright: ignore[reportPossiblyUnboundVariable] # From https://docs.djangoproject.com/en/4.0/ref/settings/#databases @@ -70,7 +70,7 @@ def config( conn_health_checks: bool = False, disable_server_side_cursors: bool = False, ssl_require: bool = False, - test_options: Optional[Dict] = None, + test_options: Optional[Dict[str, Any]] = None, ) -> DBConfig: """Returns configured DATABASE dictionary from DATABASE_URL.""" s = os.environ.get(env, default) @@ -101,7 +101,7 @@ def parse( conn_health_checks: bool = False, disable_server_side_cursors: bool = False, ssl_require: bool = False, - test_options: Optional[dict] = None, + test_options: Optional[Dict[str, Any]] = None, ) -> DBConfig: """Parses a database URL.""" if url == "sqlite://:memory:": diff --git a/pyproject.toml b/pyproject.toml index 721375d..fc6ed1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,3 +6,6 @@ show_error_codes=true disallow_untyped_defs=true disallow_untyped_calls=true warn_redundant_casts=true + +[tool.pyright] +typeCheckingMode = "strict" diff --git a/requirements.txt b/requirements.txt index 3c036d6..7ae9a96 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ coverage mypy +pyright diff --git a/setup.py b/setup.py index 5d0f474..c69e8fa 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from pathlib import Path -from setuptools import setup +from setuptools import setup # pyright: ignore[reportUnknownVariableType] readme = Path("README.rst").read_text() diff --git a/tests/test_dj_database_url.py b/tests/test_dj_database_url.py index 6e46e27..f436ac8 100644 --- a/tests/test_dj_database_url.py +++ b/tests/test_dj_database_url.py @@ -1,3 +1,5 @@ +# pyright: reportTypedDictNotRequiredAccess=false + import os import unittest from unittest import mock From 08d9cf0978f6c911417f13f441773ac569905a63 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Thu, 10 Oct 2024 23:00:30 +0100 Subject: [PATCH 11/20] Add Python 3.13 and Django 5.1 testing (#255) * Add Python 3.13 and Django 5.1 testing * Upgrade to modern actions --- .github/workflows/release.yml | 4 ++-- .github/workflows/test.yml | 20 +++++++++++--------- setup.py | 3 ++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f809ef..cf6563f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,12 +11,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.10' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30ea045..b554c12 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,8 +6,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] - django-version: ["3.2", "4.2", "5.0"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + django-version: ["3.2", "4.2", "5.1"] exclude: # Python 3.7 is not compatible with 4.1 - python-version: "3.7" @@ -17,19 +17,21 @@ jobs: django-version: "3.2" - python-version: "3.12" django-version: "3.2" - # django 5.0 is not compatible with python 3.9 or lower + - python-version: "3.13" + django-version: "3.2" + # django 5.x is not compatible with python 3.9 or lower - python-version: "3.7" - django-version: "5.0" + django-version: "5.1" - python-version: "3.8" - django-version: "5.0" + django-version: "5.1" - python-version: "3.9" - django-version: "5.0" + django-version: "5.1" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: 'pip' @@ -51,7 +53,7 @@ jobs: coverage report coverage xml - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 - name: Check types installation run: | diff --git a/setup.py b/setup.py index c69e8fa..6a7cca4 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ setup( "Framework :: Django", "Framework :: Django :: 3.2", "Framework :: Django :: 4.2", - "Framework :: Django :: 5.0", + "Framework :: Django :: 5.1", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", @@ -46,5 +46,6 @@ setup( "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ], ) From eff9f27514b5673560787fe03baad837c6521c40 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:50:06 +0100 Subject: [PATCH 12/20] [pre-commit.ci] pre-commit autoupdate (#256) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.8.0 → 24.10.0](https://github.com/psf/black/compare/24.8.0...24.10.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dc00db2..f95bd75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black args: [--target-version=py38] From 64660c7c5f960e532392352c22cb2b3744b7866f Mon Sep 17 00:00:00 2001 From: Matt Seymour Date: Wed, 23 Oct 2024 10:52:32 +0100 Subject: [PATCH 13/20] Update setup.py Updated supported versions of python and django --- setup.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 6a7cca4..bba4213 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( long_description=readme, long_description_content_type="text/x-rst", packages=["dj_database_url"], - install_requires=["Django>=3.2", "typing_extensions >= 3.10.0.0"], + install_requires=["Django>=4.2", "typing_extensions >= 3.10.0.0"], include_package_data=True, package_data={ "dj_database_url": ["py.typed"], @@ -29,8 +29,8 @@ setup( classifiers=[ "Environment :: Web Environment", "Framework :: Django", - "Framework :: Django :: 3.2", "Framework :: Django :: 4.2", + "Framework :: Django :: 5.0", "Framework :: Django :: 5.1", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", @@ -40,8 +40,6 @@ setup( "Topic :: Software Development :: Libraries :: Python Modules", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", From 396344b2510af123746219e5f7ea9b70098a74d7 Mon Sep 17 00:00:00 2001 From: Matt Seymour Date: Wed, 23 Oct 2024 10:53:25 +0100 Subject: [PATCH 14/20] Update setup.py Bump version 2.3.0 ready for next release. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bba4213..dc2eb0d 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ readme = Path("README.rst").read_text() setup( name="dj-database-url", - version="2.2.0", + version="2.3.0", url="https://github.com/jazzband/dj-database-url", license="BSD", author="Original Author: Kenneth Reitz, Maintained by: JazzBand Community", From 3505200b182cc4a1f642f94cf8f1383948497a6b Mon Sep 17 00:00:00 2001 From: Matt Seymour Date: Wed, 23 Oct 2024 10:55:15 +0100 Subject: [PATCH 15/20] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 849403a..51df3bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## v2.3.0 (2024-10-23) +* Remove Python 3.8 support. +* Remove Django 3 support. +* Add python 3.13 support. +* Add Django 5.1 to the testing library. + ## v2.2.0 (2024-05-28) * Add disable_server_side_cursors parameter * Enhance Query String Parsing for Server-Side Binding in Django 4.2 with psycopg 3.1.8+ From 0f8cfdf1c9efe8206457d3f27003589ee9ee16c5 Mon Sep 17 00:00:00 2001 From: Matt Seymour Date: Wed, 23 Oct 2024 10:57:17 +0100 Subject: [PATCH 16/20] Update test.yml --- .github/workflows/test.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b554c12..aa23a08 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,12 +6,9 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] - django-version: ["3.2", "4.2", "5.1"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + django-version: ["4.2", "5.1"] exclude: - # Python 3.7 is not compatible with 4.1 - - python-version: "3.7" - django-version: "4.2" # Python 3.11 is not compatible with 3.2 - python-version: "3.11" django-version: "3.2" @@ -20,10 +17,6 @@ jobs: - python-version: "3.13" django-version: "3.2" # django 5.x is not compatible with python 3.9 or lower - - python-version: "3.7" - django-version: "5.1" - - python-version: "3.8" - django-version: "5.1" - python-version: "3.9" django-version: "5.1" From 358746c41d022be2bab6dc7fa0ac1b98d59069f2 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:31:02 +0000 Subject: [PATCH 17/20] Drop dependency on `typing_extensions` (#257) Since it was only being used for `TypedDict`, which was added in Python 3.8 and `dj-database-url` v2.3.0+ only supports Python 3.9+. See: https://docs.python.org/3.12/library/typing.html#typing.TypedDict https://github.com/jazzband/dj-database-url/blob/master/CHANGELOG.md#v230-2024-10-23 --- CHANGELOG.md | 4 ++++ dj_database_url/__init__.py | 4 +--- setup.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51df3bd..0e085db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## Unreleased + +* Drop dependency on `typing_extensions`. + ## v2.3.0 (2024-10-23) * Remove Python 3.8 support. * Remove Django 3 support. diff --git a/dj_database_url/__init__.py b/dj_database_url/__init__.py index 2bf9d21..2cc5e16 100644 --- a/dj_database_url/__init__.py +++ b/dj_database_url/__init__.py @@ -1,9 +1,7 @@ import logging import os import urllib.parse as urlparse -from typing import Any, Dict, Optional, Union - -from typing_extensions import TypedDict +from typing import Any, Dict, Optional, TypedDict, Union DEFAULT_ENV = "DATABASE_URL" diff --git a/setup.py b/setup.py index dc2eb0d..3d7730c 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( long_description=readme, long_description_content_type="text/x-rst", packages=["dj_database_url"], - install_requires=["Django>=4.2", "typing_extensions >= 3.10.0.0"], + install_requires=["Django>=4.2"], include_package_data=True, package_data={ "dj_database_url": ["py.typed"], From 8501773f73a1c138275eddc8e0f6729fa0ef2d23 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 18:13:35 +0000 Subject: [PATCH 18/20] [pre-commit.ci] pre-commit autoupdate (#259) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/isort: 5.13.2 → 6.0.0](https://github.com/pycqa/isort/compare/5.13.2...6.0.0) - [github.com/psf/black: 24.10.0 → 25.1.0](https://github.com/psf/black/compare/24.10.0...25.1.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f95bd75..b5b64b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,13 +6,13 @@ repos: - id: trailing-whitespace - repo: https://github.com/pycqa/isort - rev: "5.13.2" + rev: "6.0.0" hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 24.10.0 + rev: 25.1.0 hooks: - id: black args: [--target-version=py38] From 5f5af493400ac74080c7a0d8f5c868be2f0d1246 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 16 Feb 2025 07:53:52 +0000 Subject: [PATCH 19/20] Fix type errors (#261) First, Mypy reported a lot of issues for the tests not including `-> None` annotations. After adding them, there were lots of issues due to the `url` variables being reassigned from `str` to `DBConfig` objects, fixed by inlining the URLs into the `parse()` calls. --- tests/test_dj_database_url.py | 278 +++++++++++++++++++--------------- 1 file changed, 153 insertions(+), 125 deletions(-) diff --git a/tests/test_dj_database_url.py b/tests/test_dj_database_url.py index f436ac8..ff690f4 100644 --- a/tests/test_dj_database_url.py +++ b/tests/test_dj_database_url.py @@ -10,9 +10,10 @@ POSTGIS_URL = "postgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compu class DatabaseTestSuite(unittest.TestCase): - def test_postgres_parsing(self): - url = "postgres://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_postgres_parsing(self) -> None: + url = dj_database_url.parse( + "postgres://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "django.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" @@ -21,9 +22,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_postgres_unix_socket_parsing(self): - url = "postgres://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_postgres_unix_socket_parsing(self) -> None: + url = dj_database_url.parse( + "postgres://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn" + ) assert url["ENGINE"] == "django.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" @@ -32,8 +34,9 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "" assert url["PORT"] == "" - url = "postgres://%2FUsers%2Fpostgres%2FRuN/d8r82722r2kuvn" - url = dj_database_url.parse(url) + url = dj_database_url.parse( + "postgres://%2FUsers%2Fpostgres%2FRuN/d8r82722r2kuvn" + ) assert url["ENGINE"] == "django.db.backends.postgresql" assert url["HOST"] == "/Users/postgres/RuN" @@ -41,9 +44,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "" assert url["PORT"] == "" - def test_postgres_google_cloud_parsing(self): - url = "postgres://uf07k1i6d8ia0v:wegauwhgeuioweg@%2Fcloudsql%2Fproject_id%3Aregion%3Ainstance_id/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_postgres_google_cloud_parsing(self) -> None: + url = dj_database_url.parse( + "postgres://uf07k1i6d8ia0v:wegauwhgeuioweg@%2Fcloudsql%2Fproject_id%3Aregion%3Ainstance_id/d8r82722r2kuvn" + ) assert url["ENGINE"] == "django.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" @@ -52,9 +56,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == "" - def test_ipv6_parsing(self): - url = "postgres://ieRaekei9wilaim7:wegauwhgeuioweg@[2001:db8:1234::1234:5678:90af]:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_ipv6_parsing(self) -> None: + url = dj_database_url.parse( + "postgres://ieRaekei9wilaim7:wegauwhgeuioweg@[2001:db8:1234::1234:5678:90af]:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "django.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" @@ -63,9 +68,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_postgres_search_path_parsing(self): - url = "postgres://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema" - url = dj_database_url.parse(url) + def test_postgres_search_path_parsing(self) -> None: + url = dj_database_url.parse( + "postgres://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema" + ) assert url["ENGINE"] == "django.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" assert url["HOST"] == "ec2-107-21-253-135.compute-1.amazonaws.com" @@ -75,9 +81,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["options"] == "-c search_path=otherschema" assert "currentSchema" not in url["OPTIONS"] - def test_postgres_parsing_with_special_characters(self): - url = "postgres://%23user:%23password@ec2-107-21-253-135.compute-1.amazonaws.com:5431/%23database" - url = dj_database_url.parse(url) + def test_postgres_parsing_with_special_characters(self) -> None: + url = dj_database_url.parse( + "postgres://%23user:%23password@ec2-107-21-253-135.compute-1.amazonaws.com:5431/%23database" + ) assert url["ENGINE"] == "django.db.backends.postgresql" assert url["NAME"] == "#database" @@ -86,9 +93,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "#password" assert url["PORT"] == 5431 - def test_postgres_parsing_with_int_bool_str_query_string(self): - url = "postgres://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?server_side_binding=true&timeout=20&service=my_service&passfile=.my_pgpass" - url = dj_database_url.parse(url) + def test_postgres_parsing_with_int_bool_str_query_string(self) -> None: + url = dj_database_url.parse( + "postgres://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?server_side_binding=true&timeout=20&service=my_service&passfile=.my_pgpass" + ) assert url["ENGINE"] == "django.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" @@ -101,9 +109,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["service"] == "my_service" assert url["OPTIONS"]["passfile"] == ".my_pgpass" - def test_postgis_parsing(self): - url = "postgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_postgis_parsing(self) -> None: + url = dj_database_url.parse( + "postgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "django.contrib.gis.db.backends.postgis" assert url["NAME"] == "d8r82722r2kuvn" @@ -112,9 +121,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_postgis_search_path_parsing(self): - url = "postgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema" - url = dj_database_url.parse(url) + def test_postgis_search_path_parsing(self) -> None: + url = dj_database_url.parse( + "postgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema" + ) assert url["ENGINE"] == "django.contrib.gis.db.backends.postgis" assert url["NAME"] == "d8r82722r2kuvn" assert url["HOST"] == "ec2-107-21-253-135.compute-1.amazonaws.com" @@ -124,9 +134,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["options"] == "-c search_path=otherschema" assert "currentSchema" not in url["OPTIONS"] - def test_mysql_gis_parsing(self): - url = "mysqlgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_mysql_gis_parsing(self) -> None: + url = dj_database_url.parse( + "mysqlgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "django.contrib.gis.db.backends.mysql" assert url["NAME"] == "d8r82722r2kuvn" @@ -135,9 +146,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_mysql_connector_parsing(self): - url = "mysql-connector://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_mysql_connector_parsing(self) -> None: + url = dj_database_url.parse( + "mysql-connector://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "mysql.connector.django" assert url["NAME"] == "d8r82722r2kuvn" @@ -146,7 +158,7 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_config_test_options(self): + def test_config_test_options(self) -> None: with mock.patch.dict( os.environ, { @@ -160,9 +172,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url['TEST']['NAME'] == 'mytestdatabase' - def test_cleardb_parsing(self): - url = "mysql://bea6eb025ca0d8:69772142@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true" - url = dj_database_url.parse(url) + def test_cleardb_parsing(self) -> None: + url = dj_database_url.parse( + "mysql://bea6eb025ca0d8:69772142@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true" + ) assert url["ENGINE"] == "django.db.backends.mysql" assert url["NAME"] == "heroku_97681db3eff7580" @@ -171,7 +184,7 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "69772142" assert url["PORT"] == "" - def test_database_url(self): + def test_database_url(self) -> None: with mock.patch.dict(os.environ, clear=True): a = dj_database_url.config() assert not a @@ -191,28 +204,28 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_empty_sqlite_url(self): - url = "sqlite://" - url = dj_database_url.parse(url) + def test_empty_sqlite_url(self) -> None: + url = dj_database_url.parse("sqlite://") assert url["ENGINE"] == "django.db.backends.sqlite3" assert url["NAME"] == ":memory:" - def test_memory_sqlite_url(self): - url = "sqlite://:memory:" - url = dj_database_url.parse(url) + def test_memory_sqlite_url(self) -> None: + url = dj_database_url.parse("sqlite://:memory:") assert url["ENGINE"] == "django.db.backends.sqlite3" assert url["NAME"] == ":memory:" - def test_parse_engine_setting(self): + def test_parse_engine_setting(self) -> None: engine = "django_mysqlpool.backends.mysqlpool" - url = "mysql://bea6eb025ca0d8:69772142@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true" - url = dj_database_url.parse(url, engine) + url = dj_database_url.parse( + "mysql://bea6eb025ca0d8:69772142@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true", + engine, + ) assert url["ENGINE"] == engine - def test_config_engine_setting(self): + def test_config_engine_setting(self) -> None: engine = "django_mysqlpool.backends.mysqlpool" with mock.patch.dict( os.environ, @@ -224,14 +237,16 @@ class DatabaseTestSuite(unittest.TestCase): assert url["ENGINE"] == engine - def test_parse_conn_max_age_setting(self): + def test_parse_conn_max_age_setting(self) -> None: conn_max_age = 600 - url = "mysql://bea6eb025ca0d8:69772142@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true" - url = dj_database_url.parse(url, conn_max_age=conn_max_age) + url = dj_database_url.parse( + "mysql://bea6eb025ca0d8:69772142@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true", + conn_max_age=conn_max_age, + ) assert url["CONN_MAX_AGE"] == conn_max_age - def test_config_conn_max_age_setting(self): + def test_config_conn_max_age_setting(self) -> None: conn_max_age = 600 with mock.patch.dict( os.environ, @@ -243,7 +258,7 @@ class DatabaseTestSuite(unittest.TestCase): assert url["CONN_MAX_AGE"] == conn_max_age - def test_database_url_with_options(self): + def test_database_url_with_options(self) -> None: # Test full options with mock.patch.dict( os.environ, @@ -274,7 +289,7 @@ class DatabaseTestSuite(unittest.TestCase): url = dj_database_url.config() assert "OPTIONS" not in url - def test_mysql_database_url_with_sslca_options(self): + def test_mysql_database_url_with_sslca_options(self) -> None: with mock.patch.dict( os.environ, { @@ -301,9 +316,8 @@ class DatabaseTestSuite(unittest.TestCase): url = dj_database_url.config() assert "OPTIONS" not in url - def test_oracle_parsing(self): - url = "oracle://scott:tiger@oraclehost:1521/hr" - url = dj_database_url.parse(url) + def test_oracle_parsing(self) -> None: + url = dj_database_url.parse("oracle://scott:tiger@oraclehost:1521/hr") assert url["ENGINE"] == "django.db.backends.oracle" assert url["NAME"] == "hr" @@ -312,9 +326,8 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "tiger" assert url["PORT"] == "1521" - def test_oracle_gis_parsing(self): - url = "oraclegis://scott:tiger@oraclehost:1521/hr" - url = dj_database_url.parse(url) + def test_oracle_gis_parsing(self) -> None: + url = dj_database_url.parse("oraclegis://scott:tiger@oraclehost:1521/hr") assert url["ENGINE"] == "django.contrib.gis.db.backends.oracle" assert url["NAME"] == "hr" @@ -323,14 +336,13 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "tiger" assert url["PORT"] == 1521 - def test_oracle_dsn_parsing(self): - url = ( + def test_oracle_dsn_parsing(self) -> None: + url = dj_database_url.parse( "oracle://scott:tiger@/" "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)" "(HOST=oraclehost)(PORT=1521)))" "(CONNECT_DATA=(SID=hr)))" ) - url = dj_database_url.parse(url) assert url["ENGINE"] == "django.db.backends.oracle" assert url["USER"] == "scott" @@ -346,9 +358,8 @@ class DatabaseTestSuite(unittest.TestCase): assert url["NAME"] == dsn - def test_oracle_tns_parsing(self): - url = "oracle://scott:tiger@/tnsname" - url = dj_database_url.parse(url) + def test_oracle_tns_parsing(self) -> None: + url = dj_database_url.parse("oracle://scott:tiger@/tnsname") assert url["ENGINE"] == "django.db.backends.oracle" assert url["USER"] == "scott" @@ -357,9 +368,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["HOST"] == "" assert url["PORT"] == "" - def test_redshift_parsing(self): - url = "redshift://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5439/d8r82722r2kuvn?currentSchema=otherschema" - url = dj_database_url.parse(url) + def test_redshift_parsing(self) -> None: + url = dj_database_url.parse( + "redshift://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5439/d8r82722r2kuvn?currentSchema=otherschema" + ) assert url["ENGINE"] == "django_redshift_backend" assert url["NAME"] == "d8r82722r2kuvn" @@ -370,9 +382,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["options"] == "-c search_path=otherschema" assert "currentSchema" not in url["OPTIONS"] - def test_mssql_parsing(self): - url = "mssql://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com/d8r82722r2kuvn?driver=ODBC Driver 13 for SQL Server" - url = dj_database_url.parse(url) + def test_mssql_parsing(self) -> None: + url = dj_database_url.parse( + "mssql://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com/d8r82722r2kuvn?driver=ODBC Driver 13 for SQL Server" + ) assert url["ENGINE"] == "sql_server.pyodbc" assert url["NAME"] == "d8r82722r2kuvn" @@ -383,9 +396,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["driver"] == "ODBC Driver 13 for SQL Server" assert "currentSchema" not in url["OPTIONS"] - def test_mssql_instance_port_parsing(self): - url = "mssql://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com\\insnsnss:12345/d8r82722r2kuvn?driver=ODBC Driver 13 for SQL Server" - url = dj_database_url.parse(url) + def test_mssql_instance_port_parsing(self) -> None: + url = dj_database_url.parse( + "mssql://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com\\insnsnss:12345/d8r82722r2kuvn?driver=ODBC Driver 13 for SQL Server" + ) assert url["ENGINE"] == "sql_server.pyodbc" assert url["NAME"] == "d8r82722r2kuvn" @@ -396,9 +410,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["driver"] == "ODBC Driver 13 for SQL Server" assert "currentSchema" not in url["OPTIONS"] - def test_cockroach(self): - url = "cockroach://testuser:testpass@testhost:26257/cockroach?sslmode=verify-full&sslrootcert=/certs/ca.crt&sslcert=/certs/client.myprojectuser.crt&sslkey=/certs/client.myprojectuser.key" - url = dj_database_url.parse(url) + def test_cockroach(self) -> None: + url = dj_database_url.parse( + "cockroach://testuser:testpass@testhost:26257/cockroach?sslmode=verify-full&sslrootcert=/certs/ca.crt&sslcert=/certs/client.myprojectuser.crt&sslkey=/certs/client.myprojectuser.key" + ) assert url['ENGINE'] == 'django_cockroachdb' assert url['NAME'] == 'cockroach' assert url['HOST'] == 'testhost' @@ -410,9 +425,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url['OPTIONS']['sslcert'] == '/certs/client.myprojectuser.crt' assert url['OPTIONS']['sslkey'] == '/certs/client.myprojectuser.key' - def test_mssqlms_parsing(self): - url = "mssqlms://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com/d8r82722r2kuvn?driver=ODBC Driver 13 for SQL Server" - url = dj_database_url.parse(url) + def test_mssqlms_parsing(self) -> None: + url = dj_database_url.parse( + "mssqlms://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com/d8r82722r2kuvn?driver=ODBC Driver 13 for SQL Server" + ) assert url["ENGINE"] == "mssql" assert url["NAME"] == "d8r82722r2kuvn" @@ -423,9 +439,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["driver"] == "ODBC Driver 13 for SQL Server" assert "currentSchema" not in url["OPTIONS"] - def test_timescale_parsing(self): - url = "timescale://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_timescale_parsing(self) -> None: + url = dj_database_url.parse( + "timescale://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "timescale.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" @@ -434,9 +451,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_timescale_unix_socket_parsing(self): - url = "timescale://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_timescale_unix_socket_parsing(self) -> None: + url = dj_database_url.parse( + "timescale://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn" + ) assert url["ENGINE"] == "timescale.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" @@ -445,8 +463,9 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "" assert url["PORT"] == "" - url = "timescale://%2FUsers%2Fpostgres%2FRuN/d8r82722r2kuvn" - url = dj_database_url.parse(url) + url = dj_database_url.parse( + "timescale://%2FUsers%2Fpostgres%2FRuN/d8r82722r2kuvn" + ) assert url["ENGINE"] == "timescale.db.backends.postgresql" assert url["HOST"] == "/Users/postgres/RuN" @@ -454,9 +473,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "" assert url["PORT"] == "" - def test_timescale_ipv6_parsing(self): - url = "timescale://ieRaekei9wilaim7:wegauwhgeuioweg@[2001:db8:1234::1234:5678:90af]:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_timescale_ipv6_parsing(self) -> None: + url = dj_database_url.parse( + "timescale://ieRaekei9wilaim7:wegauwhgeuioweg@[2001:db8:1234::1234:5678:90af]:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "timescale.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" @@ -465,9 +485,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_timescale_search_path_parsing(self): - url = "timescale://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema" - url = dj_database_url.parse(url) + def test_timescale_search_path_parsing(self) -> None: + url = dj_database_url.parse( + "timescale://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema" + ) assert url["ENGINE"] == "timescale.db.backends.postgresql" assert url["NAME"] == "d8r82722r2kuvn" assert url["HOST"] == "ec2-107-21-253-135.compute-1.amazonaws.com" @@ -477,9 +498,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["options"] == "-c search_path=otherschema" assert "currentSchema" not in url["OPTIONS"] - def test_timescale_parsing_with_special_characters(self): - url = "timescale://%23user:%23password@ec2-107-21-253-135.compute-1.amazonaws.com:5431/%23database" - url = dj_database_url.parse(url) + def test_timescale_parsing_with_special_characters(self) -> None: + url = dj_database_url.parse( + "timescale://%23user:%23password@ec2-107-21-253-135.compute-1.amazonaws.com:5431/%23database" + ) assert url["ENGINE"] == "timescale.db.backends.postgresql" assert url["NAME"] == "#database" @@ -488,9 +510,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "#password" assert url["PORT"] == 5431 - def test_timescalegis_parsing(self): - url = "timescalegis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_timescalegis_parsing(self) -> None: + url = dj_database_url.parse( + "timescalegis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "timescale.db.backends.postgis" assert url["NAME"] == "d8r82722r2kuvn" @@ -499,9 +522,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_timescalegis_unix_socket_parsing(self): - url = "timescalegis://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_timescalegis_unix_socket_parsing(self) -> None: + url = dj_database_url.parse( + "timescalegis://%2Fvar%2Frun%2Fpostgresql/d8r82722r2kuvn" + ) assert url["ENGINE"] == "timescale.db.backends.postgis" assert url["NAME"] == "d8r82722r2kuvn" @@ -510,8 +534,9 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "" assert url["PORT"] == "" - url = "timescalegis://%2FUsers%2Fpostgres%2FRuN/d8r82722r2kuvn" - url = dj_database_url.parse(url) + url = dj_database_url.parse( + "timescalegis://%2FUsers%2Fpostgres%2FRuN/d8r82722r2kuvn" + ) assert url["ENGINE"] == "timescale.db.backends.postgis" assert url["HOST"] == "/Users/postgres/RuN" @@ -519,9 +544,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "" assert url["PORT"] == "" - def test_timescalegis_ipv6_parsing(self): - url = "timescalegis://ieRaekei9wilaim7:wegauwhgeuioweg@[2001:db8:1234::1234:5678:90af]:5431/d8r82722r2kuvn" - url = dj_database_url.parse(url) + def test_timescalegis_ipv6_parsing(self) -> None: + url = dj_database_url.parse( + "timescalegis://ieRaekei9wilaim7:wegauwhgeuioweg@[2001:db8:1234::1234:5678:90af]:5431/d8r82722r2kuvn" + ) assert url["ENGINE"] == "timescale.db.backends.postgis" assert url["NAME"] == "d8r82722r2kuvn" @@ -530,9 +556,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "wegauwhgeuioweg" assert url["PORT"] == 5431 - def test_timescalegis_search_path_parsing(self): - url = "timescalegis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema" - url = dj_database_url.parse(url) + def test_timescalegis_search_path_parsing(self) -> None: + url = dj_database_url.parse( + "timescalegis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn?currentSchema=otherschema" + ) assert url["ENGINE"] == "timescale.db.backends.postgis" assert url["NAME"] == "d8r82722r2kuvn" assert url["HOST"] == "ec2-107-21-253-135.compute-1.amazonaws.com" @@ -542,9 +569,10 @@ class DatabaseTestSuite(unittest.TestCase): assert url["OPTIONS"]["options"] == "-c search_path=otherschema" assert "currentSchema" not in url["OPTIONS"] - def test_timescalegis_parsing_with_special_characters(self): - url = "timescalegis://%23user:%23password@ec2-107-21-253-135.compute-1.amazonaws.com:5431/%23database" - url = dj_database_url.parse(url) + def test_timescalegis_parsing_with_special_characters(self) -> None: + url = dj_database_url.parse( + "timescalegis://%23user:%23password@ec2-107-21-253-135.compute-1.amazonaws.com:5431/%23database" + ) assert url["ENGINE"] == "timescale.db.backends.postgis" assert url["NAME"] == "#database" @@ -553,7 +581,7 @@ class DatabaseTestSuite(unittest.TestCase): assert url["PASSWORD"] == "#password" assert url["PORT"] == 5431 - def test_persistent_connection_variables(self): + def test_persistent_connection_variables(self) -> None: url = dj_database_url.parse( "sqlite://myfile.db", conn_max_age=600, conn_health_checks=True ) @@ -561,7 +589,7 @@ class DatabaseTestSuite(unittest.TestCase): assert url["CONN_MAX_AGE"] == 600 assert url["CONN_HEALTH_CHECKS"] is True - def test_sqlite_memory_persistent_connection_variables(self): + def test_sqlite_memory_persistent_connection_variables(self) -> None: # memory sqlite ignores connection.close(), so persistent connection # variables aren’t required url = dj_database_url.parse( @@ -575,13 +603,13 @@ class DatabaseTestSuite(unittest.TestCase): os.environ, {"DATABASE_URL": "postgres://user:password@instance.amazonaws.com:5431/d8r8?"}, ) - def test_persistent_connection_variables_config(self): + def test_persistent_connection_variables_config(self) -> None: url = dj_database_url.config(conn_max_age=600, conn_health_checks=True) assert url["CONN_MAX_AGE"] == 600 assert url["CONN_HEALTH_CHECKS"] is True - def test_no_env_variable(self): + def test_no_env_variable(self) -> None: with self.assertLogs() as cm: with mock.patch.dict(os.environ, clear=True): url = dj_database_url.config() @@ -590,7 +618,7 @@ class DatabaseTestSuite(unittest.TestCase): 'WARNING:root:No DATABASE_URL environment variable set, and so no databases setup' ], cm.output - def test_bad_url_parsing(self): + def test_bad_url_parsing(self) -> None: with self.assertRaisesRegex(ValueError, "No support for 'foo'. We support: "): dj_database_url.parse("foo://bar") @@ -598,11 +626,11 @@ class DatabaseTestSuite(unittest.TestCase): os.environ, {"DATABASE_URL": "postgres://user:password@instance.amazonaws.com:5431/d8r8?"}, ) - def test_ssl_require(self): + def test_ssl_require(self) -> None: url = dj_database_url.config(ssl_require=True) assert url["OPTIONS"] == {'sslmode': 'require'} - def test_options_int_values(self): + def test_options_int_values(self) -> None: """Ensure that options with integer values are parsed correctly.""" url = dj_database_url.parse( "mysql://user:pw@127.0.0.1:15036/db?connect_timout=3" @@ -613,7 +641,7 @@ class DatabaseTestSuite(unittest.TestCase): os.environ, {"DATABASE_URL": "postgres://user:password@instance.amazonaws.com:5431/d8r8?"}, ) - def test_server_side_cursors__config(self): + def test_server_side_cursors__config(self) -> None: url = dj_database_url.config(disable_server_side_cursors=True) assert url["DISABLE_SERVER_SIDE_CURSORS"] is True From e90f97552691656b4a038b8bdf9a06fef99c33b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 09:39:28 +0100 Subject: [PATCH 20/20] [pre-commit.ci] pre-commit autoupdate (#262) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/isort: 6.0.0 → 6.0.1](https://github.com/pycqa/isort/compare/6.0.0...6.0.1) - [github.com/pycqa/flake8: 7.1.1 → 7.2.0](https://github.com/pycqa/flake8/compare/7.1.1...7.2.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5b64b0..a412573 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/pycqa/isort - rev: "6.0.0" + rev: "6.0.1" hooks: - id: isort args: ["--profile", "black"] @@ -18,6 +18,6 @@ repos: args: [--target-version=py38] - repo: https://github.com/pycqa/flake8 - rev: '7.1.1' + rev: '7.2.0' hooks: - id: flake8