Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aca45cb872
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #553 +/- ##
==========================================
- Coverage 97.58% 97.52% -0.06%
==========================================
Files 55 55
Lines 3560 3636 +76
==========================================
+ Hits 3474 3546 +72
- Misses 86 90 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Introduces static type checking (mypy + pyright) into the Python development workflow and CI, and updates the Django codebase/tests to satisfy the new type checks (plus a few related refactors and dependency adjustments).
Changes:
- Add mypy/pyright tooling (configs, dev requirements) and run them in GitHub Actions.
- Apply type annotations / assertions /
type: ignoremarkers across app code and tests to reduce type-checker noise. - Remove
django-crequestusage by passingrequestexplicitly to admin inline forms; update Matplotlib dependency and related plotting calls.
Reviewed changes
Copilot reviewed 81 out of 83 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| requirements.txt | Remove django-crequest; bump Matplotlib to >=3.8,<4. |
| requirements-dev.txt | Add mypy/pyright plus various stub packages. |
| pyrightconfig.json | Add pyright configuration and exclusions. |
| mypy.ini | Add mypy configuration and django-stubs plugin settings module. |
| enhydris_project/settings/ci.py | Make DB port a string (align with other settings). |
| enhydris_project/settings/init.py | Add typing for ENHYDRIS_SITES_FOR_NEW_STATIONS. |
| enhydris/views_common.py | Add typing to shared view utilities/mixins. |
| enhydris/views/utils.py | Make MapWithSingleStationBaseView more type-friendly; avoid try/except AttributeError. |
| enhydris/views/timeseries_group.py | Add typing and assertions for TimeseriesGroupDetail. |
| enhydris/urls.py | Add typing suppression for untyped third-party import. |
| enhydris/tests/test_views/test_station.py | Add assertions/typing tweaks for BeautifulSoup parsing and helper signatures. |
| enhydris/tests/test_views/test_auth.py | Add assertion after regex match to satisfy typing. |
| enhydris/tests/test_tasks.py | Replace chained .first().first() with safer get()/assert pattern. |
| enhydris/tests/test_models/test_timeseries_group.py | Switch .id → .pk, .first() → .get() and typing tweaks. |
| enhydris/tests/test_models/test_timeseries.py | Update test to use to_string() instead of calling __str__(timezone=...). |
| enhydris/tests/test_models/test_lentity.py | Switch .first() → .get() for single-row expectations. |
| enhydris/tests/test_models/test_gentity.py | Switch .id → .pk, .first() → .get(); add typing assertions. |
| enhydris/tests/admin/test_station.py | Remove crequest dependency in tests; update upload field name and pass explicit request to form. |
| enhydris/tests/admin/test_garea.py | Add ignores for osgeo typing; restructure patches; add type ignores where needed. |
| enhydris/tests/admin/test_admin.py | Add assertion for element existence in BeautifulSoup parsing. |
| enhydris/tests/init.py | Add typing improvements, Protocol helper, and safer super() typing. |
| enhydris/telemetry/views.py | Add runtime assertions for driver presence. |
| enhydris/telemetry/types/influxdb.py | Add assertion on cleaned_data for typing. |
| enhydris/telemetry/types/addupi.py | Add assertions around XML parsing and timestamp/value fields. |
| enhydris/telemetry/types/init.py | Type translated labels/prompts using StrOrPromise. |
| enhydris/telemetry/tests/test_views/test_telemetry_wizard_view.py | Add BeautifulSoup Tag typing/assertions; patch structure adjustments. |
| enhydris/telemetry/tests/test_views/test_telemetry_logs_view.py | Add assertions for element existence in HTML parsing. |
| enhydris/telemetry/tests/test_types/test_meteoview2.py | Make mock response setup more explicit for typing. |
| enhydris/telemetry/tests/test_types/test_addupi.py | Add ignore for untyped parameterized. |
| enhydris/telemetry/tests/test_models.py | Add ClassVar typing, mock typing, and safer null handling; adjust some datetime usage. |
| enhydris/telemetry/tests/test_forms.py | Fix setUpClass signature (cls) and store class-level attrs properly. |
| enhydris/telemetry/models.py | Add typing; refactor driver lookup import; make logging to DB more explicit/typed. |
| enhydris/telemetry/forms.py | Add assertions for cleaned_data typing. |
| enhydris/telemetry/apps.py | Add type ignore for dynamic module attribute assignment. |
| enhydris/telemetry/init.py | Add a type declaration for drivers. |
| enhydris/synoptic/views.py | Update Matplotlib API usage for grid() and set_ylim(). |
| enhydris/synoptic/tests/test_tasks.py | Typing/assertion additions; make _set_limits explicit/static and adjust call sites. |
| enhydris/synoptic/tests/test_models.py | Switch .first() → .get() for single-row expectations. |
| enhydris/synoptic/tests/data.py | Add typing and return values for helper methods; avoid relying on default_timeseries side effects. |
| enhydris/synoptic/models.py | Add postponed annotations and typed ManyToMany fields; add assertions for nullable state. |
| enhydris/synoptic/admin.py | Add typing cast for formset/form access; add resolver_match assertion. |
| enhydris/rules.py | Add pyright per-file directives. |
| enhydris/models/timeseries_group.py | Remove runtime-subscripting field annotations; switch id → pk in cache keys and __str__. |
| enhydris/models/timeseries.py | Introduce to_string() and adjust call sites; type stream inputs; adjust save() signature typing. |
| enhydris/models/gentity.py | Switch id → pk, add typing and manager annotations; use site pk set in save hook. |
| enhydris/models/base.py | Remove runtime-subscripting field annotations for compatibility with typing tools. |
| enhydris/migrations/helpers/parler.py | Add assertion after regex match for typing. |
| enhydris/migrations/0122_remove_parler_part2.py | Add typing for migration schema_editor arg. |
| enhydris/migrations/0101_squashed.py | Add # mypy: ignore-errors for legacy migration. |
| enhydris/migrations/0037_timeseries_groups.py | Add assertion for typing safety. |
| enhydris/migrations/0019_translatable_timestep.py | Add # mypy: ignore-errors for legacy migration. |
| enhydris/migrations/0015_translatable_stationtype.py | Add # mypy: ignore-errors for legacy migration. |
| enhydris/migrations/0014_translatable_variable.py | Add # mypy: ignore-errors for legacy migration. |
| enhydris/migrations/0008_join_alt_fields.py | Add assertion for regex match and unpacking safety. |
| enhydris/forms/auth.py | Add typing ignores for untyped third-party imports. |
| enhydris/autoprocess/tests/test_models/test_curve_interpolation.py | Switch .first() → .get() for single-row expectations. |
| enhydris/autoprocess/tests/test_models/test_checks.py | Switch .first() → .get() for single-row expectations. |
| enhydris/autoprocess/tests/test_models/test_autoprocess.py | Switch .first() → .get() for single-row expectations; add type attrs. |
| enhydris/autoprocess/tests/test_models/test_aggregation.py | Switch .first() → .get() for single-row expectations. |
| enhydris/autoprocess/tests/test_admin.py | Add BeautifulSoup Tag typing/assertions and .get() usage. |
| enhydris/autoprocess/models.py | Add postponed annotations; add typing for class vars and unreachable assertion. |
| enhydris/autoprocess/admin.py | Add typing ignore for nested_admin; use setattr for monkeypatch; admin field structure tweaks; add typed ClassVar field. |
| enhydris/api/views.py | Add typing to permissions return type; refactor file/image viewsets using a mixin; add a few type ignores/assertions. |
| enhydris/api/urls.py | Type urlpatterns as `URLPattern |
| enhydris/api/tests/test_views/test_timeseries_group.py | Switch .id → .pk and type helper kwargs. |
| enhydris/api/tests/test_views/test_timeseries.py | Add missing type attrs and typed empty expected list. |
| enhydris/api/tests/test_views/test_station_sort.py | Add MagicMock typing for patched args. |
| enhydris/api/tests/test_views/test_station.py | Switch .id → .pk; add types and ignores for permissions manipulation. |
| enhydris/api/tests/test_views/test_search_by_ts_has_years.py | Add postponed annotations and typed search_result. |
| enhydris/api/tests/test_views/test_search.py | Make base test case type-checkable via conditional base class; type shared attrs. |
| enhydris/api/tests/test_views/test_misc.py | Switch .id → .pk in URLs. |
| enhydris/api/tests/test_views/test_gentity_image.py | Switch .id → .pk; adjust mocks for typing. |
| enhydris/api/tests/test_views/test_gentity_file.py | Switch .id → .pk; adjust mocks for typing. |
| enhydris/api/tests/test_serializers.py | Switch .id → .pk in serializer payloads. |
| enhydris/api/tests/test_permissions.py | Switch .id → .pk in URLs. |
| enhydris/api/tests/test_auth.py | Fix import usage and type User.objects for create_user. |
| enhydris/api/serializers.py | Add generic typing; fix reverse mapping key types; add assertions for instance existence; type various serializers. |
| enhydris/admin/station.py | Remove crequest usage by passing request through inline formsets; rename upload field to data_file; typing-related adjustments. |
| enhydris/admin/garea.py | Add postponed annotations; type admin/view methods; type uploaded file handling and GDAL feature access. |
| enhydris/admin/init.py | Add TYPE_CHECKING-only generic admin base classes; adjust inlines container typing. |
| doc/conf.py | Modify Sphinx config variables to satisfy typing checks. |
| .github/workflows/run-tests.yml | Run pyright . and mypy . in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
@codex review |
There was a problem hiding this comment.
Pull request overview
Adds static type checking to the project (mypy + pyright) and updates the codebase to satisfy the new checkers, including removing the django-crequest dependency and adjusting several runtime/type annotations.
Changes:
- Add mypy/pyright tooling and run them in CI.
- Remove
django-crequestand refactor admin code to passrequestexplicitly instead of using global middleware state. - Apply widespread typing/robustness tweaks (type annotations, asserts, updated APIs like matplotlib).
Reviewed changes
Copilot reviewed 81 out of 83 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| requirements.txt | Removes django-crequest and bumps matplotlib for newer API usage. |
| requirements-dev.txt | Adds mypy/pyright and multiple typing stub packages. |
| pyrightconfig.json | Introduces pyright configuration (basic mode + excludes). |
| mypy.ini | Introduces mypy configuration and Django/DRF plugins. |
| enhydris_project/settings/ci.py | Adjusts DB port type for CI/type-checking. |
| enhydris_project/settings/init.py | Removes crequest app/middleware; adds typing for settings. |
| enhydris/views_common.py | Adds typing to shared view logic and queryset filters. |
| enhydris/views/utils.py | Refactors map view base class for better typing. |
| enhydris/views/timeseries_group.py | Adds typing and safer handling in detail view context. |
| enhydris/urls.py | Adds type-ignore for untyped third-party import. |
| enhydris/tests/test_views/test_station.py | Adds assertions/typing and adjusts selenium-clean import typing. |
| enhydris/tests/test_views/test_auth.py | Adds assertion to satisfy type checker on regex match. |
| enhydris/tests/test_tasks.py | Makes ORM fetches explicit and adds assertions for Optionals. |
| enhydris/tests/test_models/test_timeseries_group.py | Replaces .first() with .get()/.pk and tightens typing. |
| enhydris/tests/test_models/test_timeseries.py | Switches to to_string API for TimeseriesRecord. |
| enhydris/tests/test_models/test_lentity.py | Replaces .first() usage with .get() for type safety. |
| enhydris/tests/test_models/test_gentity.py | Adds typing, uses .pk, and replaces .first() with .get() in tests. |
| enhydris/tests/admin/test_station.py | Removes crequest usage; updates upload field name and passes request into form. |
| enhydris/tests/admin/test_garea.py | Adds type ignores/typing and refactors patch usage. |
| enhydris/tests/admin/test_admin.py | Adds assertion around soup lookup for typing safety. |
| enhydris/tests/init.py | Adds Protocols/annotations and typing workarounds for mixins/tests. |
| enhydris/telemetry/views.py | Adds asserts to satisfy non-Optional expectations. |
| enhydris/telemetry/types/influxdb.py | Adds assert for non-None cleaned_data. |
| enhydris/telemetry/types/addupi.py | Adds asserts around XML lookups and Optional values. |
| enhydris/telemetry/types/init.py | Adds typing for translatable labels/prompts. |
| enhydris/telemetry/tests/test_views/test_telemetry_wizard_view.py | Adds Tag typing and safer soup handling; refactors patching. |
| enhydris/telemetry/tests/test_views/test_telemetry_logs_view.py | Adds assertions around soup lookups. |
| enhydris/telemetry/tests/test_types/test_meteoview2.py | Refactors mocks to be more type-checker friendly. |
| enhydris/telemetry/tests/test_types/test_addupi.py | Adds type-ignore for untyped parameterized import. |
| enhydris/telemetry/tests/test_models.py | Adds ClassVar annotations, mock typing, and safer Optionals handling. |
| enhydris/telemetry/tests/test_forms.py | Fixes classmethod signature (cls) and class attribute assignments. |
| enhydris/telemetry/models.py | Adds typing and refactors logging and driver setup; adjusts fetch internals. |
| enhydris/telemetry/forms.py | Adds asserts for non-None cleaned_data in form cleaning. |
| enhydris/telemetry/apps.py | Adds type-ignore for dynamic module attribute assignment. |
| enhydris/telemetry/init.py | Adds typing annotation for dynamically-populated drivers. |
| enhydris/synoptic/views.py | Updates matplotlib usage for newer API (grid(visible=...), ylim tuple). |
| enhydris/synoptic/tests/test_tasks.py | Adds typing, safer soup handling, and adjusts helper signatures. |
| enhydris/synoptic/tests/test_models.py | Replaces .first() with .get() in tests. |
| enhydris/synoptic/tests/data.py | Improves typing and makes created timeseries explicit. |
| enhydris/synoptic/models.py | Adds forward annotations and typing for M2M fields; adds asserts for Optionals. |
| enhydris/synoptic/admin.py | Adds typing casts and asserts for request resolver_match. |
| enhydris/rules.py | Adds pyright directives to suppress specific reports. |
| enhydris/models/timeseries_group.py | Simplifies field typing; switches to .pk for string/caching keys. |
| enhydris/models/timeseries.py | Broad typing improvements; introduces TimeseriesRecord.to_string() and restores __str__(). |
| enhydris/models/gentity.py | Simplifies field typing; switches to .pk; adds typing for managers and save signature. |
| enhydris/models/base.py | Simplifies field typing in base Lookup model. |
| enhydris/migrations/helpers/parler.py | Adds assert for regex match result. |
| enhydris/migrations/0122_remove_parler_part2.py | Adds typing for migration function args. |
| enhydris/migrations/0101_squashed.py | Adds mypy ignore to legacy migration. |
| enhydris/migrations/0037_timeseries_groups.py | Adds assert for non-None timeseries. |
| enhydris/migrations/0019_translatable_timestep.py | Adds mypy ignore to legacy migration. |
| enhydris/migrations/0015_translatable_stationtype.py | Adds mypy ignore to legacy migration. |
| enhydris/migrations/0014_translatable_variable.py | Adds mypy ignore to legacy migration. |
| enhydris/migrations/0008_join_alt_fields.py | Adds assert for regex match result. |
| enhydris/forms/auth.py | Adds type-ignores for untyped third-party form/field imports. |
| enhydris/autoprocess/tests/test_models/test_curve_interpolation.py | Replaces .first() with .get() in tests. |
| enhydris/autoprocess/tests/test_models/test_checks.py | Replaces .first() with .get() in tests. |
| enhydris/autoprocess/tests/test_models/test_autoprocess.py | Replaces .first() with .get() and adds typing. |
| enhydris/autoprocess/tests/test_models/test_aggregation.py | Replaces .first() with .get() in tests. |
| enhydris/autoprocess/tests/test_admin.py | Adds Tag typing and safer soup lookups; replaces .first() with .get(). |
| enhydris/autoprocess/models.py | Adds typing, unreachable assert, and classvar annotations for managers. |
| enhydris/autoprocess/admin.py | Adds typing and replaces monkeypatch assignment with setattr; fixes fieldsets structure. |
| enhydris/api/views.py | Refactors file/image viewsets with a shared mixin; adds typing and ignores where needed. |
| enhydris/api/urls.py | Adds typing for urlpatterns list. |
| enhydris/api/tests/test_views/test_timeseries_group.py | Updates URLs/PK usage and adds typing in tests. |
| enhydris/api/tests/test_views/test_timeseries.py | Adds test attribute typing; refines expected type. |
| enhydris/api/tests/test_views/test_station_sort.py | Adds MagicMock typing for patched call assertions. |
| enhydris/api/tests/test_views/test_station.py | Switches to .pk and adds typing in helper. |
| enhydris/api/tests/test_views/test_search_by_ts_has_years.py | Adds forward annotations and better typed expectations. |
| enhydris/api/tests/test_views/test_search.py | Adds TYPE_CHECKING base-class workaround and typed class attributes. |
| enhydris/api/tests/test_views/test_misc.py | Switches URL building to .pk. |
| enhydris/api/tests/test_views/test_gentity_image.py | Switches URL building to .pk and refines mocks. |
| enhydris/api/tests/test_views/test_gentity_file.py | Switches URL building to .pk and refines mocks. |
| enhydris/api/tests/test_serializers.py | Switches FK IDs in payloads to .pk. |
| enhydris/api/tests/test_permissions.py | Switches station/timeseries group IDs to .pk in URLs. |
| enhydris/api/tests/test_auth.py | Adjusts imports/typing and adds asserts for regex/body types. |
| enhydris/api/serializers.py | Adds serializer generics/typing improvements and refines type field mapping. |
| enhydris/admin/station.py | Removes crequest dependency; renames upload field; passes request through inline formset. |
| enhydris/admin/garea.py | Adds typing and TYPE_CHECKING bases; refines shapefile upload handling. |
| enhydris/admin/init.py | Adds TYPE_CHECKING admin bases and tweaks inline tuple usage. |
| doc/conf.py | Adds typing for Sphinx extensions. |
| .github/workflows/run-tests.yml | Runs pyright and mypy in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Checklist: