Skip to content

Commit 4f451a3

Browse files
J0joel@joellee.orgsourcery-ai[bot]
authored
chore: update pre-commit (#209)
* chore: update pre-commit * fix: convert to string * fix: drop py37 * 'Refactored by Sourcery' (#210) Co-authored-by: Sourcery AI <> --------- Co-authored-by: [email protected] <[email protected]> Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
1 parent ecc6e79 commit 4f451a3

File tree

7 files changed

+100
-104
lines changed

7 files changed

+100
-104
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest]
11-
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
11+
python-version: [3.8, 3.9, '3.10', '3.11']
1212
runs-on: ${{ matrix.os }}
1313
steps:
1414
- name: Clone Repository

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
args: ["--fix=lf"]
1010

1111
- repo: https://github.com/pycqa/isort
12-
rev: 5.10.1
12+
rev: "5.12.0"
1313
hooks:
1414
- id: isort
1515
args:
@@ -35,7 +35,7 @@ repos:
3535
]
3636

3737
- repo: https://github.com/psf/black
38-
rev: "22.3.0"
38+
rev: "23.1.0"
3939
hooks:
4040
- id: black
4141
args: [--line-length, "90"]

poetry.lock

+84-85
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

postgrest/_async/request_builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def upsert(
280280
count=count,
281281
returning=returning,
282282
ignore_duplicates=ignore_duplicates,
283-
on_conflict=on_conflict
283+
on_conflict=on_conflict,
284284
)
285285
return AsyncQueryRequestBuilder(
286286
self.session, self.path, method, headers, params, json

postgrest/_sync/request_builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def upsert(
280280
count=count,
281281
returning=returning,
282282
ignore_duplicates=ignore_duplicates,
283-
on_conflict=on_conflict
283+
on_conflict=on_conflict,
284284
)
285285
return SyncQueryRequestBuilder(
286286
self.session, self.path, method, headers, params, json

postgrest/base_request_builder.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ def pre_select(
4141
else:
4242
method = RequestMethod.HEAD
4343
params = QueryParams()
44-
if count:
45-
headers = Headers({"Prefer": f"count={count}"})
46-
else:
47-
headers = Headers()
44+
headers = Headers({"Prefer": f"count={count}"}) if count else Headers()
4845
return QueryArgs(method, params, headers, {})
4946

5047

@@ -70,9 +67,9 @@ def pre_upsert(
7067
count: Optional[CountMethod],
7168
returning: ReturnMethod,
7269
ignore_duplicates: bool,
73-
on_conflict: str= "",
70+
on_conflict: str = "",
7471
) -> QueryArgs:
75-
query_params = dict()
72+
query_params = {}
7673
prefer_headers = [f"return={returning}"]
7774
if count:
7875
prefer_headers.append(f"count={count}")
@@ -127,9 +124,7 @@ def _get_count_from_content_range_header(
127124
content_range_header: str,
128125
) -> Optional[int]:
129126
content_range = content_range_header.split("/")
130-
if len(content_range) < 2:
131-
return None
132-
return int(content_range[1])
127+
return None if len(content_range) < 2 else int(content_range[1])
133128

134129
@staticmethod
135130
def _is_count_in_prefer_header(prefer_header: str) -> bool:
@@ -148,9 +143,11 @@ def _get_count_from_http_request_response(
148143
content_range_header: Optional[str] = request_response.headers.get(
149144
"content-range"
150145
)
151-
if not (is_count_in_prefer_header and content_range_header):
152-
return None
153-
return cls._get_count_from_content_range_header(content_range_header)
146+
return (
147+
cls._get_count_from_content_range_header(content_range_header)
148+
if (is_count_in_prefer_header and content_range_header)
149+
else None
150+
)
154151

155152
@classmethod
156153
def from_http_request_response(
@@ -381,7 +378,7 @@ def adj(self: _FilterT, column: str, range: Tuple[int, int]) -> _FilterT:
381378
def match(self: _FilterT, query: Dict[str, Any]) -> _FilterT:
382379
updated_query = self
383380

384-
if len(query) == 0:
381+
if not query:
385382
raise ValueError(
386383
"query dictionary should contain at least one key-value pair"
387384
)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ packages = [
1818
]
1919

2020
[tool.poetry.dependencies]
21-
python = "^3.7"
21+
python = "^3.8"
2222
httpx = "^0.23.0"
2323
deprecation = "^2.1.0"
2424
pydantic = "^1.9.0"

0 commit comments

Comments
 (0)