Skip to content

Commit 9364517

Browse files
committed
pre-commit; backup calculator
1 parent df4ee1a commit 9364517

82 files changed

Lines changed: 708 additions & 308 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,6 @@ CouchbaseMock*.jar
180180
gocaves*
181181
.pytest_cache/
182182
test_scripts/
183+
184+
# rff
185+
.ruff_cache/

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
args: [--allow-multiple-documents]
9+
- id: check-added-large-files
10+
- id: check-toml
11+
- id: check-merge-conflict
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
# Ruff version.
14+
rev: v0.12.1
15+
hooks:
16+
# Run the linter.
17+
- id: ruff-check
18+
types_or: [ python, pyi ]
19+
# Run the formatter.
20+
# - id: ruff-format
21+
# types_or: [ python, pyi ]
22+
# Compile requirements
23+
- repo: https://github.com/astral-sh/uv-pre-commit
24+
# uv version.
25+
rev: 0.7.19
26+
hooks:
27+
# Compile requirements
28+
- id: pip-compile
29+
name: pip-compile requirements.in
30+
args: [requirements.in, --python-version, '3.9', --universal, -o, requirements.txt]
31+
- id: pip-compile
32+
name: pip-compile requirements-dev.in
33+
args: [requirements-dev.in, --python-version, '3.9', --universal, -o, requirements-dev.txt]
34+
files: ^requirements-dev\.(in|txt)$
35+
- id: pip-compile
36+
name: pip-compile requirements-sphinx.in
37+
args: [requirements-sphinx.in, --python-version, '3.9', --universal, -o, requirements-sphinx.txt]
38+
files: ^requirements-sphinx\.(in|txt)$

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ exclude couchbase_analytics/tests/*.py
77
recursive-include acouchbase_analytics *.py
88
exclude acouchbase_analytics/tests/*.py
99
global-exclude *.py[cod] *.DS_Store
10-
exclude .git .gitignore .gitmodules gocaves* *.jar .clang* .cmake* .pre* .flake* MANIFEST.in
10+
exclude .git .gitignore .gitmodules gocaves* *.jar .clang* .cmake* .pre* .flake* MANIFEST.in

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Couchbase Python Analytics Client
2-
Python client for [Couchbase](https://couchbase.com) Analytics.
2+
Python client for [Couchbase](https://couchbase.com) Analytics.

acouchbase_analytics/cluster.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,3 @@ class AsyncCluster:
113113
credential: Credential,
114114
options: ClusterOptions,
115115
**kwargs: Unpack[ClusterOptionsKwargs]) -> AsyncCluster: ...
116-

acouchbase_analytics/protocol/_core/anyio_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def current_async_library() -> Optional[AsyncBackend]:
4747
import sniffio
4848
except ImportError:
4949
async_lib = 'asyncio'
50-
50+
5151
# TODO: This helps make tests work.
5252
# Should we work through the scenario when sniffio cannot find the async library?
5353
try:
@@ -62,4 +62,4 @@ def current_async_library() -> Optional[AsyncBackend]:
6262
if async_lib == 'trio':
6363
raise RuntimeError('trio currently not supported')
6464

65-
return AsyncBackend(async_lib)
65+
return AsyncBackend(async_lib)

acouchbase_analytics/protocol/_core/async_json_stream.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def has_results_or_errors(self) -> Event:
6060
**INTERNAL**
6161
"""
6262
return self._has_results_or_errors_evt
63-
63+
6464
@property
6565
def results_or_errors_type(self) -> ParsedResultType:
6666
"""
@@ -74,7 +74,7 @@ def token_stream_exhausted(self) -> bool:
7474
**INTERNAL**
7575
"""
7676
return self._token_stream_exhausted
77-
77+
7878
def _continue_processing(self) -> bool:
7979
"""
8080
**INTERNAL**
@@ -108,7 +108,7 @@ async def _handle_json_result(self, row: bytes) -> None:
108108
def _handle_notification(self, result_type: Optional[ParsedResultType]=None) -> None:
109109
if self._has_results_or_errors_evt.is_set():
110110
return
111-
111+
112112
if result_type is None:
113113
self._results_or_errors_type = ParsedResultType.END
114114
self._has_results_or_errors_evt.set()
@@ -140,14 +140,14 @@ async def _process_token_stream(self) -> None:
140140
result_type = ParsedResultType.ERROR if self._json_token_parser.has_errors else ParsedResultType.END
141141
await self._send_to_stream(ParsedResult(self._json_token_parser.get_result(), result_type), close=True)
142142
self._handle_notification(result_type)
143-
143+
144144
async def read(self, size: Optional[int]=-1) -> bytes:
145145
"""
146146
**INTERNAL**
147147
"""
148148
if size is None or size == 0 or self._http_stream_exhausted:
149149
return b''
150-
150+
151151
while not self._http_stream_exhausted:
152152
if size >= 0 and len(self._http_response_buffer) > size:
153153
break
@@ -181,4 +181,4 @@ async def start_parsing(self) -> None:
181181

182182
async def continue_parsing(self) -> None:
183183
# TODO: error is _json_stream_parser is None?
184-
await self._process_token_stream()
184+
await self._process_token_stream()

acouchbase_analytics/protocol/_core/async_json_token_parser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def _handle_obj_emit(self, obj: str) -> bool:
4040
await self._results_handler(bytes(obj, 'utf-8'))
4141
return True
4242
return False
43-
43+
4444
async def _handle_pop_event(self, token_type: TokenType) -> None:
4545
matching_token = self._get_matching_token(token_type)
4646
obj_pairs: List[str] = []
@@ -53,16 +53,16 @@ async def _handle_pop_event(self, token_type: TokenType) -> None:
5353
obj = f'[{",".join(reversed(obj_pairs))}]'
5454
else:
5555
obj = f'{{{",".join(reversed(obj_pairs))}}}'
56-
56+
5757
if should_emit:
5858
object_emitted = await self._handle_obj_emit(obj)
5959
if object_emitted:
6060
break # this means we emiited the result/error, so stop processing the stack
6161

6262
if len(self._stack) > 0 and self._stack[-1].type == TokenType.MAP_KEY:
6363
map_key = self._pop()
64-
# If we are emitting rows and/or errors,
65-
# we don't keep them in the stack and therefore don't need to return the results
64+
# If we are emitting rows and/or errors,
65+
# we don't keep them in the stack and therefore don't need to return the results
6666
if self._should_push_pair(next_token):
6767
self._push(TokenType.PAIR, f'{map_key.value}:{obj}')
6868
else:
@@ -88,4 +88,4 @@ async def parse_token(self, token: str, value: str) -> None:
8888
await self._handle_pop_event(token_type)
8989
else:
9090
# TODO: custom exception
91-
raise ValueError(f'Invalid token type: {token_type}; {value=}')
91+
raise ValueError(f'Invalid token type: {token_type}; {value=}')

acouchbase_analytics/protocol/_core/client_adapter.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ def analytics_path(self) -> str:
5757
"""
5858
**INTERNAL**
5959
"""
60-
return self._ANALYTICS_PATH
61-
60+
return self._ANALYTICS_PATH
61+
6262
@property
6363
def client(self) -> AsyncClient:
6464
"""
6565
**INTERNAL**
6666
"""
6767
return self._client
68-
68+
6969
@property
7070
def client_id(self) -> str:
7171
"""
@@ -86,7 +86,7 @@ def default_deserializer(self) -> Deserializer:
8686
**INTERNAL**
8787
"""
8888
return self._conn_details.default_deserializer
89-
89+
9090
@property
9191
def has_client(self) -> bool:
9292
"""
@@ -137,7 +137,7 @@ async def send_request(self, request: QueryRequest) -> Response:
137137
"""
138138
if not hasattr(self, '_client'):
139139
raise RuntimeError('Client not created yet')
140-
140+
141141
# if request.url is None:
142142
# raise ValueError('Request URL cannot be None')
143143

@@ -161,4 +161,3 @@ def reset_client(self) -> None:
161161
"""
162162
if hasattr(self, '_client'):
163163
del self._client
164-

acouchbase_analytics/protocol/_core/net_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ async def get_request_ip_async(host: str,
5454
ip_str = str(ip) if not isinstance(ip, str) else ip
5555
ip = None if ip_str in previous_ips else ip_str
5656

57-
return ip
57+
return ip

0 commit comments

Comments
 (0)