Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Sync dependencies
run: uv sync --locked --dev

- name: Type check
- name: Pyrefly type check
run: ./scripts/typecheck.sh

test:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ repos:
language: system
always_run: true
pass_filenames: false
- id: mypy
name: mypy
- id: pyrefly
name: pyrefly
entry: ./scripts/typecheck.sh
language: system
always_run: true
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ gmaps-scraper = "gmaps_scraper.cli:main"

[dependency-groups]
dev = [
"mypy",
"prek",
"pyrefly>=1.1.1",
"ruff",
]

Expand All @@ -33,10 +33,11 @@ exclude-newer = "7 days"
[tool.hatch.build.targets.wheel]
packages = ["src/gmaps_scraper"]

[tool.mypy]
files = ["src"]
python_version = "3.14"
strict = true
[tool.pyrefly]
project-includes = ["src"]
python-version = "3.14"
preset = "strict"
check-unannotated-defs = true
Comment on lines +39 to +40

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve strict annotation checks

When a new src function has annotated parameters but omits -> ..., this config no longer fails the typecheck gate: Pyrefly documents unannotated-return as default ignore, and check-unannotated-defs only checks function bodies, while the removed mypy strict = true enabled --disallow-untyped-defs/--disallow-incomplete-defs. Add the equivalent Pyrefly error overrides, e.g. for missing return annotations, if the previous strict typed-API gate is meant to be preserved.

Useful? React with 👍 / 👎.


[tool.ruff]
line-length = 100
Expand Down
6 changes: 5 additions & 1 deletion scripts/typecheck.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail

uv run mypy
if [[ "${GITHUB_ACTIONS:-}" == "true" ]]; then
uv run pyrefly check --output-format=github
else
uv run pyrefly check --summarize-errors
fi
4 changes: 3 additions & 1 deletion src/gmaps_scraper/display_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ def _repaired_display_diagnostics(
repair_source: str,
) -> PlaceExtractionDiagnostics:
existing = place.diagnostics
quality_flags = list(existing.quality_flags) if existing is not None else []
quality_flags: list[str] = (
list(existing.quality_flags) if existing is not None else []
)
if "category_display_en" in repaired_fields:
quality_flags = [
flag for flag in quality_flags if flag != "needs_category_display_en"
Expand Down
2 changes: 1 addition & 1 deletion src/gmaps_scraper/place_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3317,7 +3317,7 @@ def _build_place_diagnostics(

raw_sources = snapshot.get("field_sources")
field_sources = {
key: str(value)
key: value
for key, value in raw_sources.items()
if isinstance(key, str)
and isinstance(value, str)
Expand Down
18 changes: 12 additions & 6 deletions src/gmaps_scraper/translation_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,20 @@ def _merge_learned_translation_memory(
candidates: list[dict[str, object]],
) -> None:
existing = _read_pending_payload(path)
entries = existing.setdefault("entries", [])
if not isinstance(entries, list):
raw_entries = existing.setdefault("entries", [])
if isinstance(raw_entries, list):
entries: list[object] = raw_entries
else:
entries = []
existing["entries"] = entries
index: dict[tuple[object, object, tuple[object, ...]], dict[object, object]] = {}
for entry in entries:
if not isinstance(entry, dict):
continue
field_kinds = entry.get("field_kinds")
if not isinstance(field_kinds, list):
raw_field_kinds = entry.get("field_kinds")
if isinstance(raw_field_kinds, list):
field_kinds: list[object] = raw_field_kinds
else:
field_kinds = []
index[(entry.get("source"), entry.get("target"), tuple(field_kinds))] = entry
for candidate in candidates:
Expand Down Expand Up @@ -263,8 +267,10 @@ def _write_json_atomic(path: Path, payload: Mapping[str, object]) -> None:


def _memory_entry_key(entry: Mapping[str, object]) -> tuple[object, object, tuple[object, ...]]:
field_kinds = entry.get("field_kinds")
if not isinstance(field_kinds, list):
raw_field_kinds = entry.get("field_kinds")
if isinstance(raw_field_kinds, list):
field_kinds: list[object] = raw_field_kinds
else:
field_kinds = []
return (entry.get("source"), entry.get("target"), tuple(field_kinds))

Expand Down
96 changes: 21 additions & 75 deletions uv.lock

Large diffs are not rendered by default.

Loading