refactor: Move imports to top and centralize API URLs#4
Merged
Conversation
This commit makes two code organization improvements: 1. Move all inline imports to the top of their respective files - Follows Python convention (PEP 8) - Improves static analysis and IDE support - Makes dependencies visible at a glance 2. Centralize API URLs in settings.py - CENSUSMAPPER_API_URL for api/v1 endpoints - CENSUSMAPPER_DATA_URL for data_sets endpoints - Single source of truth eliminates drift risk Files modified: - settings.py: Add URL constants - core.py: Move json, io, hashlib imports; use URL constant - vectors.py: Move io, warnings imports; use URL constant - regions.py: Move io import; use URL constant - datasets.py: Move re import; use URL constant - hierarchy.py: Move re import to top - intersect_geometry.py: Reorganize imports; use URL constant - resilience.py: Move atexit import to top All existing tests pass unchanged, confirming no behavioral impact. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The unconditional import of RPythonBridge was causing CI failures since the cross_validation module is only available locally. Wrap the import in try/except like other test files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update actions/checkout@v3 → v4 in validate_examples.yml - Update actions/upload-artifact@v3 → v4 in validate_examples.yml - Update codecov/codecov-action@v3 → v4 in ci.yml These v3 actions are deprecated and cause CI warnings/failures. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
settings.pyChanges
CENSUSMAPPER_API_URLandCENSUSMAPPER_DATA_URLconstants tosettings.pycore.py,vectors.py,regions.py,datasets.py,hierarchy.py,intersect_geometry.py,resilience.pyWhy
Test plan
pytest tests/test_basic.py)🤖 Generated with Claude Code