From bfd7d1a7c70e510994c4a8e5ac7e878ec46c63a3 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Fri, 31 Jan 2025 15:14:20 -0600 Subject: [PATCH 1/4] add pre-commit run --- .github/workflows/pre-commit.yaml | 31 +++++++++++++++++++++++++++++++ .gitignore | 3 +++ 2 files changed, 34 insertions(+) create mode 100644 .github/workflows/pre-commit.yaml diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..89b693c --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,31 @@ +name: pre-commit + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + pre-commit: + name: "pre-commit" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: pre-commit (cache) + uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + - name: pre-commit (--all-files) + run: | + python -m pip install pre-commit + pre-commit run --show-diff-on-failure --color=always --all-files diff --git a/.gitignore b/.gitignore index 51206dc..9c5ac24 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ + +.vscode + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] From 575a90d06928b8800e1b7ad39347783d985cc6a2 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Fri, 31 Jan 2025 15:21:58 -0600 Subject: [PATCH 2/4] try a few --- .pre-commit-config.yaml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6799d58..0e00bc4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,42 @@ fail_fast: true repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/ambv/black - rev: 24.2.0 + rev: 25.1.0 hooks: - id: black - args: [--diff, --check] + types_or: python - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.7.0 + rev: v1.14.1 hooks: - id: mypy exclude: ^tests/ verbose: true - entry: bash -c '"$@" || true' -- + + - repo: https://github.com/PyCQA/flake8 + rev: 7.1.1 + hooks: + - id: flake8 + types_or: [python] + + - repo: https://github.com/PyCQA/isort + rev: 6.0.0 + hooks: + - id: isort + + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell + additional_dependencies: [tomli] - repo: https://github.com/compilerla/conventional-pre-commit rev: v3.1.0 From c27066e539861a7d912076f74d8483b9fd581622 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Fri, 31 Jan 2025 15:24:12 -0600 Subject: [PATCH 3/4] typo --- .github/workflows/pypi-publish.yaml | 2 +- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi-publish.yaml b/.github/workflows/pypi-publish.yaml index 9b3b32c..5d0f621 100644 --- a/.github/workflows/pypi-publish.yaml +++ b/.github/workflows/pypi-publish.yaml @@ -29,4 +29,4 @@ jobs: run: | poetry build - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e00bc4..bdfcf82 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: rev: 25.1.0 hooks: - id: black - types_or: python + types_or: [python] - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.14.1 From 60292ff5abdb39dc87be33541009ad7b1f82086a Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Fri, 31 Jan 2025 15:35:40 -0600 Subject: [PATCH 4/4] add a sort of standard one --- .pre-commit-config.yaml | 27 +++++---------------------- README.md | 2 +- tests/smoke.py | 2 -- wherobots/db/__init__.py | 26 +++++++++++++++++++++++++- wherobots/db/cursor.py | 1 - wherobots/db/driver.py | 2 -- 6 files changed, 31 insertions(+), 29 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bdfcf82..8edc001 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,29 +8,12 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/ambv/black - rev: 25.1.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.5 hooks: - - id: black - types_or: [python] - - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.14.1 - hooks: - - id: mypy - exclude: ^tests/ - verbose: true - - - repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 - hooks: - - id: flake8 - types_or: [python] - - - repo: https://github.com/PyCQA/isort - rev: 6.0.0 - hooks: - - id: isort + - id: ruff + args: [ --fix ] + - id: ruff-format - repo: https://github.com/codespell-project/codespell rev: v2.4.1 diff --git a/README.md b/README.md index 1ddb3a2..4915f76 100644 --- a/README.md +++ b/README.md @@ -82,5 +82,5 @@ users may find useful: convenient for human inspection while still being usable by libraries like Shapely. * `reuse_session`: controls whether an existing runtime of the same type - and in the same region that is available should be re-used for this + and in the same region that is available should be reused for this connection. This is the default behavior. diff --git a/tests/smoke.py b/tests/smoke.py index 641f2e8..5425944 100644 --- a/tests/smoke.py +++ b/tests/smoke.py @@ -13,8 +13,6 @@ from wherobots.db import connect, connect_direct from wherobots.db.constants import DEFAULT_ENDPOINT from wherobots.db.connection import Connection -from wherobots.db.region import Region -from wherobots.db.runtime import Runtime if __name__ == "__main__": parser = argparse.ArgumentParser() diff --git a/wherobots/db/__init__.py b/wherobots/db/__init__.py index 348de14..3e9a96e 100644 --- a/wherobots/db/__init__.py +++ b/wherobots/db/__init__.py @@ -1,6 +1,30 @@ from .connection import Connection from .cursor import Cursor from .driver import connect, connect_direct -from .errors import * +from .errors import ( + Error, + DatabaseError, + InternalError, + InterfaceError, + OperationalError, + ProgrammingError, + NotSupportedError, +) from .region import Region from .runtime import Runtime + +__all__ = [ + "Connection", + "Cursor", + "connect", + "connect_direct", + "Error", + "DatabaseError", + "InternalError", + "InterfaceError", + "OperationalError", + "ProgrammingError", + "NotSupportedError", + "Region", + "Runtime", +] diff --git a/wherobots/db/cursor.py b/wherobots/db/cursor.py index e20c12d..b12187e 100644 --- a/wherobots/db/cursor.py +++ b/wherobots/db/cursor.py @@ -15,7 +15,6 @@ class Cursor: - def __init__(self, exec_fn, cancel_fn) -> None: self.__exec_fn = exec_fn self.__cancel_fn = cancel_fn diff --git a/wherobots/db/driver.py b/wherobots/db/driver.py index 1bd982c..f8a770d 100644 --- a/wherobots/db/driver.py +++ b/wherobots/db/driver.py @@ -8,7 +8,6 @@ import logging from packaging.version import Version import platform -import queue import requests import tenacity from typing import Union, Dict @@ -170,7 +169,6 @@ def connect_direct( data_compression: Union[DataCompression, None] = None, geometry_representation: Union[GeometryRepresentation, None] = None, ) -> Connection: - q = queue.SimpleQueue() uri_with_protocol = f"{uri}/{protocol}" try: