Skip to content

Commit

Permalink
build: updated deps, switched to ruff for pyupgrade+format
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Sep 29, 2024
1 parent 38acb84 commit bf8129e
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 447 deletions.
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@ test-examples:
cd examples; yes | python3 load_dataframe.py
cd examples; python3 working_hours.py 'activitywatch|aw-|github.com' fakedata

typecheck:
poetry run mypy

PYFILES=aw_client/*.py examples/*.py

lint:
ruff check .

lint-fix:
pyupgrade --py38-plus ${PYFILES} --exit-zero-even-if-changed
ruff check --fix .

typecheck:
poetry run mypy

format:
black .
ruff format .

clean:
rm -rf build dist
Expand Down
12 changes: 3 additions & 9 deletions aw_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ def __init__(

server_host = host or server_config["hostname"]
server_port = port or server_config["port"]
self.server_address = "{protocol}://{host}:{port}".format(
protocol=protocol, host=server_host, port=server_port
)
self.server_address = f"{protocol}://{server_host}:{server_port}"

self.instance = SingleInstance(
f"{self.client_name}-at-{server_host}-on-{server_port}"
Expand Down Expand Up @@ -445,9 +443,7 @@ def _try_connect(self) -> bool:
self._create_buckets()
self.connected = True
logger.info(
"Connection to aw-server established by {}".format(
self.client.client_name
)
f"Connection to aw-server established by {self.client.client_name}"
)
except req.RequestException:
self.connected = False
Expand Down Expand Up @@ -511,9 +507,7 @@ def run(self) -> None:
# Connect
while not self._try_connect():
logger.warning(
"Not connected to server, {} requests in queue".format(
self._persistqueue.qsize()
)
f"Not connected to server, {self._persistqueue.qsize()} requests in queue"
)
if self.wait(self._attempt_reconnect_interval):
break
Expand Down
2 changes: 1 addition & 1 deletion aw_client/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EnhancedJSONEncoder(json.JSONEncoder):

def default(self, o):
if dataclasses.is_dataclass(o):
return dataclasses.asdict(o)
return dataclasses.asdict(o) # type: ignore
return super().default(o)


Expand Down
2 changes: 1 addition & 1 deletion examples/working_hours.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def query(regex: str, timeperiods, hostname: str):
)
]

aw = aw_client.ActivityWatchClient()
aw = aw_client.ActivityWatchClient(client_name="working_hours")

canonicalQuery = queries.canonicalEvents(
queries.DesktopQueryParams(
Expand Down
Loading

0 comments on commit bf8129e

Please sign in to comment.