-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[f] Upgrade Python version from 3.9 to 3.11 #13
Conversation
WalkthroughThe pull request introduces updates to the Python version across multiple GitHub Actions workflow files and the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CI
participant Archive
participant Cron
participant Pipfile
User->>CI: Trigger CI workflow
CI->>CI: Set up Python 3.11
CI->>Archive: Run Archive workflow
Archive->>Archive: Set up Python 3.11
Archive->>Cron: Run Cron workflow
Cron->>Cron: Set up Python 3.11
Pipfile->>Pipfile: Update Python version to 3.11
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
Pipfile (1)
Line range hint
1-23
: Consider pinning dependency versions for better reproducibility.Most of your dependencies use "*" which could lead to unexpected breaking changes. Consider pinning versions, especially for critical dependencies like
scrapy
andscrapy-wayback-middleware
.Example of pinned versions:
[packages] -scrapy = "*" +scrapy = "~=2.11.0" scrapy-sentry-errors = "1.0.0" city-scrapers-core = {ref = "main", git = "https://github.com/City-Bureau/city-scrapers-core.git", extras = ["azure"]} -scrapy-wayback-middleware = "*" +scrapy-wayback-middleware = "~=0.3.0" -python-dateutil = "*" +python-dateutil = "~=2.8.2" -importlib-resources = "*" +importlib-resources = "~=6.1.1" -pdfminer-six = "*" +pdfminer-six = "~=20221105".github/workflows/cron.yml (1)
10-10
: LGTM! Python 3.11 upgrade looks good.The upgrade to Python 3.11 is a good choice as it brings significant performance improvements, especially for CPU-intensive tasks like web scraping. The version is consistently referenced throughout the workflow.
You might see improved scraping performance due to Python 3.11's optimizations, particularly:
- Up to 10-60% faster CPU-intensive tasks
- Improved error messages
- Enhanced typing system
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
Pipfile.lock
is excluded by!**/*.lock
📒 Files selected for processing (4)
.github/workflows/archive.yml
(1 hunks).github/workflows/ci.yml
(1 hunks).github/workflows/cron.yml
(1 hunks)Pipfile
(1 hunks)
🔇 Additional comments (6)
Pipfile (1)
23-23
: LGTM on Python version upgrade!
The upgrade to Python 3.11 is a good choice as it offers significant performance improvements over 3.9.
Let's verify the compatibility of city-scrapers-core with Python 3.11:
✅ Verification successful
Python 3.11 upgrade is compatible with dependencies
The verification shows that city-scrapers-core supports Python versions >=3.6,<4.0
, which includes Python 3.11. The package's dependencies (jsonschema, pytz, requests, scrapy) are all mature packages with Python 3.11 support.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if city-scrapers-core main branch supports Python 3.11
gh repo clone City-Bureau/city-scrapers-core
cd city-scrapers-core
rg -l "python_version|Python" setup.py pyproject.toml
Length of output: 234
Script:
#!/bin/bash
# Check the content of setup.py to verify Python version requirements
cat city-scrapers-core/setup.py
Length of output: 1160
.github/workflows/archive.yml (2)
Line range hint 31-35
: Cache configuration looks good
The cache key properly includes the Python version, which will automatically invalidate caches when switching between Python versions. This ensures clean dependency installations.
10-10
: LGTM! Verify dependency compatibility with Python 3.11
The Python version upgrade to 3.11 is a good move as it brings performance improvements and new features. However, we should ensure all dependencies are compatible with Python 3.11.
Let's verify the dependencies compatibility:
✅ Verification successful
Python 3.11 upgrade is compatible with all dependencies
The verification shows that:
- All dependencies in Pipfile are specified with flexible version constraints (
*
) exceptblack==22.6
- Core dependencies like
scrapy
,python-dateutil
, and others don't have Python version constraints - Requirements files show compatible versions of common packages
- No Python version-specific dependencies or markers are found that would conflict with Python 3.11
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check Pipfile.lock for any potential compatibility issues with Python 3.11
# Test: Look for any version constraints or Python version specifications in Pipfile
cat Pipfile | grep -A 5 "python_version"
# Test: Check if there are any known problematic dependencies
cat Pipfile.lock | jq -r '.default | keys[]' | while read pkg; do
echo "Checking $pkg..."
rg --type=yaml "package: $pkg" -A 5 -g "*.yml"
done
Length of output: 228
Script:
#!/bin/bash
# Let's verify Python dependencies and their compatibility
# Check Pipfile for Python version and dependencies
echo "=== Checking Pipfile ==="
cat Pipfile
# Check if there are any Python version specific dependencies or markers
echo -e "\n=== Checking requirements files ==="
fd "requirements.*\.txt$" --exec cat {}
# Check workflow files for any Python package installation steps
echo -e "\n=== Checking workflow files for package installation ==="
fd "\.yml$" --type f -E "**/node_modules/**" -E "**/.git/**" --exec grep -l "pip install\|poetry install\|pipenv install" {} \; | while read -r file; do
echo "=== $file ==="
cat "$file"
done
Length of output: 1157
.github/workflows/cron.yml (2)
Line range hint 39-43
: Verify cache behavior after Python version upgrade.
The cache key strategy is well-implemented, using both Python version and Pipfile.lock for specificity. The version change will naturally invalidate old caches, ensuring clean dependency installation.
Let's verify the Pipfile.lock compatibility:
✅ Verification successful
Cache configuration is correctly aligned with Python version requirements
The verification confirms that the Pipfile.lock specifies Python 3.11, which matches the cache key strategy in the workflow. The cache invalidation will work as expected when Python versions change.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if Pipfile.lock exists and verify its Python version requirement
# Test: Check if Pipfile.lock exists and contains Python 3.11
if [ -f "Pipfile.lock" ]; then
echo "Checking Pipfile.lock Python version..."
jq -r '."_meta".requires.python_version' Pipfile.lock
fi
# Test: Look for any version-specific dependencies
rg -l "python_version" Pipfile.lock
Length of output: 224
Line range hint 52-56
: Consider adjusting scraper concurrency settings.
With Python 3.11's improved performance, you might want to experiment with the AUTOTHROTTLE_TARGET_CONCURRENCY
setting (currently set to 3.0 in the environment variables) to potentially handle more concurrent requests.
Let's check the current concurrency settings:
.github/workflows/ci.yml (1)
18-18
: LGTM! Verify dependency compatibility with Python 3.11
The Python version upgrade looks good. The workflow configuration properly handles the new version through the matrix strategy and cache keys.
Let's verify the project's dependencies are compatible with Python 3.11:
✅ Verification successful
All dependencies are compatible with Python 3.11
Based on the Pipfile.lock analysis:
- All production dependencies have version constraints that include Python 3.11
- Development dependencies (black, flake8, pytest, etc.) also support Python 3.11
- No packages have upper version bounds that would conflict with Python 3.11
- The only package with a potential constraint is
zipp
which is only required for Python < 3.10, but this is not an issue for 3.11
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check Pipfile.lock for any potential Python 3.11 compatibility issues
# Test: Look for any version constraints or Python requirements in Pipfile
rg -A 5 'python_version|requires' Pipfile
# Test: Check Pipfile.lock for any packages with Python version constraints
rg -A 5 '"markers"|"python_version"' Pipfile.lock
Length of output: 15973
@@ -15,7 +15,7 @@ jobs: | |||
strategy: | |||
max-parallel: 4 | |||
matrix: | |||
python-version: [3.9] | |||
python-version: [3.11] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding explicit Python compatibility checks
To ensure a smooth transition to Python 3.11, consider adding checks for Python 3.11 syntax compatibility.
Add a step to verify Python compatibility:
- name: Lint with flake8
run: |
pipenv run flake8 .
+ - name: Check Python compatibility
+ run: |
+ pipenv install pyupgrade
+ pipenv run pyupgrade --py311-plus **/*.py
+
- name: Test with pytest
Committable suggestion was skipped due to low confidence.
Description
Summary by CodeRabbit
New Features
Bug Fixes