Skip to content

Commit

Permalink
chore: update pre-commit (#209)
Browse files Browse the repository at this point in the history
* chore: update pre-commit

* fix: convert to string

* fix: drop py37

* 'Refactored by Sourcery' (#210)

Co-authored-by: Sourcery AI <>

---------

Co-authored-by: joel@joellee.org <joel@joellee.org>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 7, 2023
1 parent ecc6e79 commit 4f451a3
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
python-version: [3.8, 3.9, '3.10', '3.11']
runs-on: ${{ matrix.os }}
steps:
- name: Clone Repository
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -9,7 +9,7 @@ repos:
args: ["--fix=lf"]

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: "5.12.0"
hooks:
- id: isort
args:
Expand All @@ -35,7 +35,7 @@ repos:
]

- repo: https://github.com/psf/black
rev: "22.3.0"
rev: "23.1.0"
hooks:
- id: black
args: [--line-length, "90"]
Expand Down
169 changes: 84 additions & 85 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion postgrest/_async/request_builder.py
Expand Up @@ -280,7 +280,7 @@ def upsert(
count=count,
returning=returning,
ignore_duplicates=ignore_duplicates,
on_conflict=on_conflict
on_conflict=on_conflict,
)
return AsyncQueryRequestBuilder(
self.session, self.path, method, headers, params, json
Expand Down
2 changes: 1 addition & 1 deletion postgrest/_sync/request_builder.py
Expand Up @@ -280,7 +280,7 @@ def upsert(
count=count,
returning=returning,
ignore_duplicates=ignore_duplicates,
on_conflict=on_conflict
on_conflict=on_conflict,
)
return SyncQueryRequestBuilder(
self.session, self.path, method, headers, params, json
Expand Down
23 changes: 10 additions & 13 deletions postgrest/base_request_builder.py
Expand Up @@ -41,10 +41,7 @@ def pre_select(
else:
method = RequestMethod.HEAD
params = QueryParams()
if count:
headers = Headers({"Prefer": f"count={count}"})
else:
headers = Headers()
headers = Headers({"Prefer": f"count={count}"}) if count else Headers()
return QueryArgs(method, params, headers, {})


Expand All @@ -70,9 +67,9 @@ def pre_upsert(
count: Optional[CountMethod],
returning: ReturnMethod,
ignore_duplicates: bool,
on_conflict: str= "",
on_conflict: str = "",
) -> QueryArgs:
query_params = dict()
query_params = {}
prefer_headers = [f"return={returning}"]
if count:
prefer_headers.append(f"count={count}")
Expand Down Expand Up @@ -127,9 +124,7 @@ def _get_count_from_content_range_header(
content_range_header: str,
) -> Optional[int]:
content_range = content_range_header.split("/")
if len(content_range) < 2:
return None
return int(content_range[1])
return None if len(content_range) < 2 else int(content_range[1])

@staticmethod
def _is_count_in_prefer_header(prefer_header: str) -> bool:
Expand All @@ -148,9 +143,11 @@ def _get_count_from_http_request_response(
content_range_header: Optional[str] = request_response.headers.get(
"content-range"
)
if not (is_count_in_prefer_header and content_range_header):
return None
return cls._get_count_from_content_range_header(content_range_header)
return (
cls._get_count_from_content_range_header(content_range_header)
if (is_count_in_prefer_header and content_range_header)
else None
)

@classmethod
def from_http_request_response(
Expand Down Expand Up @@ -381,7 +378,7 @@ def adj(self: _FilterT, column: str, range: Tuple[int, int]) -> _FilterT:
def match(self: _FilterT, query: Dict[str, Any]) -> _FilterT:
updated_query = self

if len(query) == 0:
if not query:
raise ValueError(
"query dictionary should contain at least one key-value pair"
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -18,7 +18,7 @@ packages = [
]

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
httpx = "^0.23.0"
deprecation = "^2.1.0"
pydantic = "^1.9.0"
Expand Down

0 comments on commit 4f451a3

Please sign in to comment.