Skip to content

Commit 73207fa

Browse files
authored
chore: Refactor pre-commit config and test on CI (#27)
1 parent 7c44afd commit 73207fa

File tree

9 files changed

+77
-18
lines changed

9 files changed

+77
-18
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: pre-commit
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
pre-commit:
16+
name: "pre-commit"
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.x'
23+
- name: pre-commit (cache)
24+
uses: actions/cache@v4
25+
with:
26+
path: ~/.cache/pre-commit
27+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
28+
- name: pre-commit (--all-files)
29+
run: |
30+
python -m pip install pre-commit
31+
pre-commit run --show-diff-on-failure --color=always --all-files

.github/workflows/pypi-publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
run: |
3030
poetry build
3131
- name: Publish package distributions to PyPI
32-
uses: pypa/gh-action-pypi-publish@release/v1
32+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
.vscode
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

.pre-commit-config.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
fail_fast: true
22

33
repos:
4-
- repo: https://github.com/ambv/black
5-
rev: 24.2.0
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
66
hooks:
7-
- id: black
8-
args: [--diff, --check]
7+
- id: check-yaml
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace
910

10-
- repo: https://github.com/pre-commit/mirrors-mypy
11-
rev: v1.7.0
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.1.5
1213
hooks:
13-
- id: mypy
14-
exclude: ^tests/
15-
verbose: true
16-
entry: bash -c '"$@" || true' --
14+
- id: ruff
15+
args: [ --fix ]
16+
- id: ruff-format
17+
18+
- repo: https://github.com/codespell-project/codespell
19+
rev: v2.4.1
20+
hooks:
21+
- id: codespell
22+
additional_dependencies: [tomli]
1723

1824
- repo: https://github.com/compilerla/conventional-pre-commit
1925
rev: v3.1.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ users may find useful:
8282
convenient for human inspection while still being usable by
8383
libraries like Shapely.
8484
* `reuse_session`: controls whether an existing runtime of the same type
85-
and in the same region that is available should be re-used for this
85+
and in the same region that is available should be reused for this
8686
connection. This is the default behavior.

tests/smoke.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from wherobots.db import connect, connect_direct
1414
from wherobots.db.constants import DEFAULT_ENDPOINT
1515
from wherobots.db.connection import Connection
16-
from wherobots.db.region import Region
17-
from wherobots.db.runtime import Runtime
1816

1917
if __name__ == "__main__":
2018
parser = argparse.ArgumentParser()

wherobots/db/__init__.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
from .connection import Connection
22
from .cursor import Cursor
33
from .driver import connect, connect_direct
4-
from .errors import *
4+
from .errors import (
5+
Error,
6+
DatabaseError,
7+
InternalError,
8+
InterfaceError,
9+
OperationalError,
10+
ProgrammingError,
11+
NotSupportedError,
12+
)
513
from .region import Region
614
from .runtime import Runtime
15+
16+
__all__ = [
17+
"Connection",
18+
"Cursor",
19+
"connect",
20+
"connect_direct",
21+
"Error",
22+
"DatabaseError",
23+
"InternalError",
24+
"InterfaceError",
25+
"OperationalError",
26+
"ProgrammingError",
27+
"NotSupportedError",
28+
"Region",
29+
"Runtime",
30+
]

wherobots/db/cursor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
class Cursor:
18-
1918
def __init__(self, exec_fn, cancel_fn) -> None:
2019
self.__exec_fn = exec_fn
2120
self.__cancel_fn = cancel_fn

wherobots/db/driver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import logging
99
from packaging.version import Version
1010
import platform
11-
import queue
1211
import requests
1312
import tenacity
1413
from typing import Union, Dict
@@ -170,7 +169,6 @@ def connect_direct(
170169
data_compression: Union[DataCompression, None] = None,
171170
geometry_representation: Union[GeometryRepresentation, None] = None,
172171
) -> Connection:
173-
q = queue.SimpleQueue()
174172
uri_with_protocol = f"{uri}/{protocol}"
175173

176174
try:

0 commit comments

Comments
 (0)