Skip to content

Commit

Permalink
Fix types/formatting in map_syncer and pin tools versions
Browse files Browse the repository at this point in the history
Pinning tools version might be good idea to avoid spurious type
and format checking issues when pushing unrelated changes.
  • Loading branch information
p2004a committed Nov 26, 2023
1 parent 4a85414 commit 9b801af
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_tools_map_syncer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:
- name: Check Types
run: mypy
- name: Lint
run: ruff . --format=github
run: ruff check --output-format=github .
- name: Test
run: pytest
2 changes: 1 addition & 1 deletion tools/map_syncer/map_syncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class SyncOp(Enum):
STOP = 2


if TYPE_CHECKING: # noqa: SIM108
if TYPE_CHECKING:
SyncQueue = queue.Queue[Tuple[SyncOp, str]]
else:
SyncQueue = queue.Queue
Expand Down
9 changes: 5 additions & 4 deletions tools/map_syncer/map_syncer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_poller_starts_sync_correctly(mocker: MockerFixture) -> None:
sync_trigger: map_syncer.SyncQueue = queue.Queue()
t = threading.Thread(
target=lambda: map_syncer.polling_sync(
pathlib.Path(""), "", 0, sync_trigger, "http://x.com/health"
pathlib.Path(), "", 0, sync_trigger, "http://x.com/health"
)
)
t.start()
Expand All @@ -245,7 +245,7 @@ def test_poller_catches_exceptions(mocker: MockerFixture) -> None:
sync_files.side_effect = RuntimeError("test")
sync_trigger: map_syncer.SyncQueue = queue.Queue()
t = threading.Thread(
target=lambda: map_syncer.polling_sync(pathlib.Path(""), "", 0, sync_trigger)
target=lambda: map_syncer.polling_sync(pathlib.Path(), "", 0, sync_trigger)
)
t.start()
sync_trigger.put((map_syncer.SyncOp.SYNC, "A"))
Expand All @@ -260,7 +260,7 @@ def test_poller_ignores_duplicate_requests(mocker: MockerFixture) -> None:
sync_files = mocker.patch("map_syncer.sync_files")
sync_trigger: map_syncer.SyncQueue = queue.Queue()
t = threading.Thread(
target=lambda: map_syncer.polling_sync(pathlib.Path(""), "", 0, sync_trigger)
target=lambda: map_syncer.polling_sync(pathlib.Path(), "", 0, sync_trigger)
)
t.start()
for _ in range(10):
Expand Down Expand Up @@ -322,7 +322,8 @@ def test_sync_files_deletes_only_old(live_maps_url: str, fs: FakeFilesystem) ->
assert fs.exists(d / "map_old_1.sd7")
assert not fs.exists(d / "map_old_2.sd7")
assert cast(
Dict[str, int], json.loads(fs.get_object(d / "tombstones.json").contents)
Dict[str, int],
json.loads(fs.get_object(d / "tombstones.json").contents or "{}"),
) == {
"map_old_1.sd7": initial_tombstones["map_old_1.sd7"],
}
18 changes: 9 additions & 9 deletions tools/map_syncer/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
black>=23.3.0
isort>=5.12.0
mypy>=1.4.1
black==23.11.0
isort==5.12.0
mypy==1.7.1
paho-mqtt>=1.6.1
pyfakefs>=5.2.2
pyfakefs>=5.3.1
pytest-httpserver>=1.0.8
pytest-mock>=3.11.1
pytest-mqtt>=0.2.0
pytest>=7.4.0
ruff>=0.0.277
types-paho-mqtt>=1.6.0.6
pytest-mock>=3.12.0
pytest-mqtt>=0.3.1
pytest>=7.4.3
ruff==0.1.6
types-paho-mqtt>=1.6.0.7

0 comments on commit 9b801af

Please sign in to comment.