Skip to content

chore: Refactor pre-commit config and test on CI #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/pypi-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
run: |
poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
26 changes: 16 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
fail_fast: true

repos:
- repo: https://github.com/ambv/black
rev: 24.2.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: black
args: [--diff, --check]
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.5
hooks:
- id: mypy
exclude: ^tests/
verbose: true
entry: bash -c '"$@" || true' --
- id: ruff
args: [ --fix ]
- id: ruff-format

- 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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 0 additions & 2 deletions tests/smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
26 changes: 25 additions & 1 deletion wherobots/db/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
1 change: 0 additions & 1 deletion wherobots/db/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class Cursor:

def __init__(self, exec_fn, cancel_fn) -> None:
self.__exec_fn = exec_fn
self.__cancel_fn = cancel_fn
Expand Down
2 changes: 0 additions & 2 deletions wherobots/db/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import logging
from packaging.version import Version
import platform
import queue
import requests
import tenacity
from typing import Union, Dict
Expand Down Expand Up @@ -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:
Expand Down