GitHub Actions commited on
Commit
6affa2f
·
1 Parent(s): d6ca3a2

fix: re-apply Python 3.10 UTC compatibility (was reverted by formatter)

Browse files

The formatter reverted our UTC → timezone.utc changes.
Re-applied the fix across all 10 files to support Python 3.10 on HF Space.

Files fixed:
- hearthnet/services/chat/service.py
- hearthnet/events/snapshot.py
- hearthnet/events/log.py
- hearthnet/identity/manifest.py
- hearthnet/ui/onboarding.py
- hearthnet/transport/server.py
- hearthnet/transport/client.py
- hearthnet/services/marketplace/views.py
- hearthnet/services/marketplace/service.py
- hearthnet/services/marketplace/post.py

hearthnet/discovery/udp.py CHANGED
@@ -117,10 +117,9 @@ class UdpListener:
117
  try:
118
  sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
119
  sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
120
- try:
 
121
  sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) # type: ignore[attr-defined]
122
- except (AttributeError, OSError):
123
- pass
124
  sock.bind(("", self._port))
125
  mcast_req = struct.pack("4sL", socket.inet_aton(UDP_MULTICAST_GROUP), socket.INADDR_ANY)
126
  sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mcast_req)
 
117
  try:
118
  sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
119
  sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
120
+ from contextlib import suppress
121
+ with suppress(AttributeError, OSError):
122
  sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) # type: ignore[attr-defined]
 
 
123
  sock.bind(("", self._port))
124
  mcast_req = struct.pack("4sL", socket.inet_aton(UDP_MULTICAST_GROUP), socket.INADDR_ANY)
125
  sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mcast_req)
hearthnet/events/log.py CHANGED
@@ -15,9 +15,9 @@ import json
15
  import sqlite3
16
  import threading
17
  from collections.abc import AsyncIterator
18
- from datetime import UTC, datetime
19
 
20
- UTC = UTC
21
  import contextlib
22
  from pathlib import Path
23
  from typing import Any
 
15
  import sqlite3
16
  import threading
17
  from collections.abc import AsyncIterator
18
+ from datetime import datetime, timezone
19
 
20
+ UTC = timezone.utc
21
  import contextlib
22
  from pathlib import Path
23
  from typing import Any
hearthnet/events/snapshot.py CHANGED
@@ -4,9 +4,9 @@ import base64
4
  import json
5
  import os
6
  from dataclasses import dataclass
7
- from datetime import UTC, datetime
8
 
9
- UTC = UTC
10
  import contextlib
11
  from pathlib import Path
12
  from typing import TYPE_CHECKING, Any
 
4
  import json
5
  import os
6
  from dataclasses import dataclass
7
+ from datetime import datetime, timezone
8
 
9
+ UTC = timezone.utc
10
  import contextlib
11
  from pathlib import Path
12
  from typing import TYPE_CHECKING, Any
hearthnet/identity/keys.py CHANGED
@@ -245,10 +245,9 @@ def save(kp: KeyPair, keys_dir: Path) -> None:
245
  sk_bytes = bytes(kp.signing_key)
246
  priv_path.write_bytes(base64.urlsafe_b64encode(sk_bytes).rstrip(b"=") + b"\n")
247
  # Restrict permissions on POSIX
248
- try:
 
249
  os.chmod(priv_path, stat.S_IRUSR | stat.S_IWUSR) # 0600
250
- except AttributeError:
251
- pass # Windows: chmod semantics differ; best-effort
252
  # Write public key
253
  vk_bytes = bytes(kp.verify_key)
254
  pub_path.write_bytes(base64.urlsafe_b64encode(vk_bytes).rstrip(b"=") + b"\n")
 
245
  sk_bytes = bytes(kp.signing_key)
246
  priv_path.write_bytes(base64.urlsafe_b64encode(sk_bytes).rstrip(b"=") + b"\n")
247
  # Restrict permissions on POSIX
248
+ from contextlib import suppress
249
+ with suppress(AttributeError):
250
  os.chmod(priv_path, stat.S_IRUSR | stat.S_IWUSR) # 0600
 
 
251
  # Write public key
252
  vk_bytes = bytes(kp.verify_key)
253
  pub_path.write_bytes(base64.urlsafe_b64encode(vk_bytes).rstrip(b"=") + b"\n")
hearthnet/identity/manifest.py CHANGED
@@ -1,9 +1,9 @@
1
  from __future__ import annotations
2
 
3
  from dataclasses import dataclass
4
- from datetime import UTC, datetime, timedelta
5
 
6
- UTC = UTC
7
  from typing import Any
8
 
9
  from hearthnet.identity.keys import (
 
1
  from __future__ import annotations
2
 
3
  from dataclasses import dataclass
4
+ from datetime import datetime, timedelta, timezone
5
 
6
+ UTC = timezone.utc
7
  from typing import Any
8
 
9
  from hearthnet.identity.keys import (
hearthnet/observability/otlp_export.py CHANGED
@@ -159,13 +159,10 @@ class OtlpExporter:
159
 
160
  async def shutdown(self) -> None:
161
  """Flush and shut down the underlying providers."""
 
162
  if self._meter_provider is not None:
163
- try:
164
  self._meter_provider.shutdown() # type: ignore[union-attr]
165
- except Exception:
166
- pass
167
  if self._tracer_provider is not None:
168
- try:
169
  self._tracer_provider.shutdown() # type: ignore[union-attr]
170
- except Exception:
171
- pass
 
159
 
160
  async def shutdown(self) -> None:
161
  """Flush and shut down the underlying providers."""
162
+ from contextlib import suppress
163
  if self._meter_provider is not None:
164
+ with suppress(Exception):
165
  self._meter_provider.shutdown() # type: ignore[union-attr]
 
 
166
  if self._tracer_provider is not None:
167
+ with suppress(Exception):
168
  self._tracer_provider.shutdown() # type: ignore[union-attr]
 
 
hearthnet/relay/client.py CHANGED
@@ -204,8 +204,6 @@ class RelayClient:
204
  with contextlib.suppress(asyncio.CancelledError):
205
  await self._keepalive_task
206
  if self._httpx_client is not None:
207
- try:
208
  await self._httpx_client.aclose() # type: ignore[union-attr]
209
- except Exception:
210
- pass
211
  self._httpx_client = None
 
204
  with contextlib.suppress(asyncio.CancelledError):
205
  await self._keepalive_task
206
  if self._httpx_client is not None:
207
+ with contextlib.suppress(Exception):
208
  await self._httpx_client.aclose() # type: ignore[union-attr]
 
 
209
  self._httpx_client = None
hearthnet/relay/push_subscriber.py CHANGED
@@ -100,9 +100,8 @@ class PushSubscriber:
100
 
101
  async def close(self) -> None:
102
  """Close the internal httpx client."""
 
103
  if self._httpx_client is not None:
104
- try:
105
  await self._httpx_client.aclose() # type: ignore[union-attr]
106
- except Exception:
107
- pass
108
  self._httpx_client = None
 
100
 
101
  async def close(self) -> None:
102
  """Close the internal httpx client."""
103
+ from contextlib import suppress
104
  if self._httpx_client is not None:
105
+ with suppress(Exception):
106
  await self._httpx_client.aclose() # type: ignore[union-attr]
 
 
107
  self._httpx_client = None
hearthnet/services/chat/service.py CHANGED
@@ -1,9 +1,9 @@
1
  from __future__ import annotations
2
 
3
  import uuid
4
- from datetime import UTC, datetime
5
 
6
- UTC = UTC
7
 
8
  from hearthnet.bus.capability import CapabilityDescriptor, RouteRequest
9
  from hearthnet.services.chat.delivery import DeliveryManager
 
1
  from __future__ import annotations
2
 
3
  import uuid
4
+ from datetime import datetime, timezone
5
 
6
+ UTC = timezone.utc
7
 
8
  from hearthnet.bus.capability import CapabilityDescriptor, RouteRequest
9
  from hearthnet.services.chat.delivery import DeliveryManager
hearthnet/services/marketplace/post.py CHANGED
@@ -1,9 +1,9 @@
1
  from __future__ import annotations
2
 
3
  from dataclasses import dataclass
4
- from datetime import UTC, datetime
5
 
6
- UTC = UTC
7
  from typing import Literal
8
 
9
  Category = Literal["offer", "request", "info", "emergency"]
 
1
  from __future__ import annotations
2
 
3
  from dataclasses import dataclass
4
+ from datetime import datetime, timezone
5
 
6
+ UTC = timezone.utc
7
  from typing import Literal
8
 
9
  Category = Literal["offer", "request", "info", "emergency"]
hearthnet/services/marketplace/service.py CHANGED
@@ -1,9 +1,9 @@
1
  from __future__ import annotations
2
 
3
  import uuid
4
- from datetime import UTC, datetime, timedelta
5
 
6
- UTC = UTC
7
 
8
  from hearthnet.bus.capability import CapabilityDescriptor, RouteRequest
9
  from hearthnet.constants import MARKET_DEFAULT_TTL_SECONDS
 
1
  from __future__ import annotations
2
 
3
  import uuid
4
+ from datetime import datetime, timedelta, timezone
5
 
6
+ UTC = timezone.utc
7
 
8
  from hearthnet.bus.capability import CapabilityDescriptor, RouteRequest
9
  from hearthnet.constants import MARKET_DEFAULT_TTL_SECONDS
hearthnet/services/marketplace/views.py CHANGED
@@ -1,6 +1,8 @@
1
  from __future__ import annotations
2
 
3
- from datetime import UTC, datetime
 
 
4
 
5
  UTC = UTC
6
 
 
1
  from __future__ import annotations
2
 
3
+ from datetime import datetime, timezone
4
+
5
+ UTC = timezone.utc
6
 
7
  UTC = UTC
8
 
hearthnet/transport/client.py CHANGED
@@ -7,9 +7,9 @@ import json
7
  import secrets
8
  from collections.abc import AsyncIterator
9
  from dataclasses import dataclass, field
10
- from datetime import UTC, datetime
11
 
12
- UTC = UTC
13
 
14
  try:
15
  import httpx
 
7
  import secrets
8
  from collections.abc import AsyncIterator
9
  from dataclasses import dataclass, field
10
+ from datetime import datetime, timezone
11
 
12
+ UTC = timezone.utc
13
 
14
  try:
15
  import httpx
hearthnet/transport/server.py CHANGED
@@ -21,9 +21,9 @@ from __future__ import annotations
21
 
22
  import asyncio
23
  from collections.abc import Callable
24
- from datetime import UTC, datetime
25
 
26
- UTC = UTC
27
  from typing import Any
28
 
29
  try:
 
21
 
22
  import asyncio
23
  from collections.abc import Callable
24
+ from datetime import datetime, timezone
25
 
26
+ UTC = timezone.utc
27
  from typing import Any
28
 
29
  try:
hearthnet/ui/__pycache__/app.cpython-313.pyc CHANGED
Binary files a/hearthnet/ui/__pycache__/app.cpython-313.pyc and b/hearthnet/ui/__pycache__/app.cpython-313.pyc differ
 
hearthnet/ui/__pycache__/onboarding.cpython-313.pyc CHANGED
Binary files a/hearthnet/ui/__pycache__/onboarding.cpython-313.pyc and b/hearthnet/ui/__pycache__/onboarding.cpython-313.pyc differ
 
hearthnet/ui/onboarding.py CHANGED
@@ -5,9 +5,9 @@ from __future__ import annotations
5
  import base64
6
  import json
7
  from dataclasses import dataclass
8
- from datetime import UTC
9
 
10
- UTC = UTC
11
 
12
  import contextlib
13
 
 
5
  import base64
6
  import json
7
  from dataclasses import dataclass
8
+ from datetime import timezone
9
 
10
+ UTC = timezone.utc
11
 
12
  import contextlib
13
 
hearthnet/ui/tabs/__pycache__/ask.cpython-313.pyc CHANGED
Binary files a/hearthnet/ui/tabs/__pycache__/ask.cpython-313.pyc and b/hearthnet/ui/tabs/__pycache__/ask.cpython-313.pyc differ
 
hearthnet/ui/tabs/__pycache__/chat.cpython-313.pyc CHANGED
Binary files a/hearthnet/ui/tabs/__pycache__/chat.cpython-313.pyc and b/hearthnet/ui/tabs/__pycache__/chat.cpython-313.pyc differ
 
hearthnet/ui/tabs/__pycache__/files.cpython-313.pyc CHANGED
Binary files a/hearthnet/ui/tabs/__pycache__/files.cpython-313.pyc and b/hearthnet/ui/tabs/__pycache__/files.cpython-313.pyc differ
 
hearthnet/ui/tabs/__pycache__/getting_started.cpython-313.pyc CHANGED
Binary files a/hearthnet/ui/tabs/__pycache__/getting_started.cpython-313.pyc and b/hearthnet/ui/tabs/__pycache__/getting_started.cpython-313.pyc differ
 
hearthnet/ui/tabs/__pycache__/mesh.cpython-313.pyc CHANGED
Binary files a/hearthnet/ui/tabs/__pycache__/mesh.cpython-313.pyc and b/hearthnet/ui/tabs/__pycache__/mesh.cpython-313.pyc differ
 
hearthnet/ui/tabs/__pycache__/settings.cpython-313.pyc CHANGED
Binary files a/hearthnet/ui/tabs/__pycache__/settings.cpython-313.pyc and b/hearthnet/ui/tabs/__pycache__/settings.cpython-313.pyc differ