Skip to content

Conversation

@AlexandreSinger
Copy link
Contributor

@AlexandreSinger AlexandreSinger commented Dec 20, 2025

The python linter test was in the "test" workflow when it should be in the "lint" worflow. Moved it over.

While moving it, I noticed that it was on such an old version of PyLint that it could not even run on Ubuntu 24.04's version of Python. Upgraded the version of PyLint to make the test more stable. To do this, I had to resolve many lint issues in the Python files. I ignored the consider using f-string warning since so many files use format instead. I also increased the max positional arguments since so many files use 25+ positional arguments.

Summary by CodeRabbit

Release Notes

  • Chores

    • Added dedicated Python linting automation to CI/CD pipeline
    • Updated Python linting tool to latest version with enhanced checks
    • Improved UTF-8 encoding consistency across file I/O operations throughout codebase
    • Refined code formatting and whitespace across development utilities for improved consistency
    • Enhanced error handling with more specific exception types
  • Tests

    • Reorganized Python linting to dedicated CI job for better separation of concerns

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added VPR VPR FPGA Placement & Routing Tool Odin Odin II Logic Synthesis Tool: Unsorted item docs Documentation infra Project Infrastructure scripts Utility & Infrastructure scripts lang-python Python code tests labels Dec 20, 2025
@AlexandreSinger
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2025

Walkthrough

This PR modernizes the codebase through CI workflow restructuring, pylint version upgrade from 2.7.4 to 4.0.4, systematic UTF-8 encoding standardization across file I/O operations, extensive whitespace cleanup, and minor code quality improvements including better exception handling and context manager usage.

Changes

Cohort / File(s) Summary
CI Workflow Configuration
\.github/workflows/lint\.yml, \.github/workflows/test\.yml
Added new independent PythonLint job to lint.yml with checkout, requirements install, and pylint execution steps; removed Python Lint matrix entry from test.yml Format job.
Pylint Configuration & Dependencies
dev/pylint_check\.py, requirements\.txt
Updated pylint from 2.7.4 to 4.0.4; replaced ignored check C0330 with C0209 (consider-using-f-string); added --max-positional-arguments=30 flag to pylint command.
UTF-8 File Encoding Standardization
vtr_flow/scripts/python_libs/vtr/*, vtr_flow/scripts/noc/noc_benchmark_test\.py, vtr_flow/scripts/run_vtr_flow\.py, vtr_flow/scripts/run_vtr_task\.py, vtr_flow/scripts/tuning_runs/control_runs\.py, vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened\.py, dev/vtr_test_suite_verifier/verify_test_suites\.py
Added explicit encoding="utf-8" parameter to file open operations across multiple scripts for consistent text decoding on all platforms.
Whitespace & Formatting Cleanup
dev/annealing_curve_plotter\.py, dev/external_subtrees\.py, dev/submit_slurm\.py, doc/src/vtr_version\.py, odin_ii/regression_test/parse_result/*, odin_ii/regression_test/tools/parse_odin_result\.py, vpr/scripts/compare_timing_reports\.py, vpr/scripts/profile/parse_and_plot_detailed\.py, vtr_flow/scripts/blif_splicer\.py, vtr_flow/scripts/download_ispd\.py, vtr_flow/scripts/download_titan\.py, vtr_flow/scripts/upgrade_arch\.py, vtr_flow/scripts/benchtracker/*, vtr_flow/scripts/arch_gen/arch_gen\.py, vtr_flow/scripts/qor_compare\.py, run_reg_test\.py
Removed extraneous blank lines throughout codebase; no functional changes to control flow, logic, or error handling.
Functional Improvements & Refactoring
vtr_flow/scripts/download_symbiflow\.py, vtr_flow/scripts/ispd2vtr\.py, vtr_flow/scripts/python_libs/vtr/task\.py, vtr_flow/scripts/python_libs/vtr/log_parse\.py, vtr_flow/scripts/python_libs/vtr/util\.py
Context manager improvements for HTTP responses; replaced broad exceptions with specific types (FileNotFoundError, ValueError); consolidated conditional logic with max(); replaced dynamic XML parser import with direct ElementTree; added pylint directives for specific warnings.

Possibly Related PRs

Suggested Reviewers

  • AmirhosseinPoolad

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[CI] Moved and Updated Python Lint Test' accurately reflects the main changes: relocating the Python linter from the test workflow to the lint workflow and upgrading PyLint version.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-ci

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (4)
vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened.py (1)

18-44: Consider adding error handling for file operations.

While the UTF-8 encoding additions are excellent, the file operations lack error handling for scenarios such as missing files, permission issues, or I/O errors. Adding try-except blocks around file operations would improve robustness.

🔎 Example error handling pattern
try:
    with open(file, "r", encoding="utf-8") as f:
        for line in f:
            if top_module_regex.search(line):
                return file
except (IOError, OSError) as e:
    print(f"Warning: Could not read {file}: {e}")
    continue
vtr_flow/scripts/noc/noc_benchmark_test.py (1)

299-299: LGTM! More specific exception types improve error clarity.

Changing from generic exceptions to ValueError is appropriate for these parsing validation errors. The descriptive messages clearly indicate what went wrong.

Static analysis suggests avoiding long messages outside exception classes (TRY003). While the current approach is acceptable, you could optionally define custom exception classes if these errors need structured handling in the future:

Optional refactor to custom exception classes
class PlacementDataError(ValueError):
    """Base class for placement data parsing errors"""
    pass

class PlacementCostError(PlacementDataError):
    """Raised when placement cost is not written correctly"""
    pass

# Then use:
raise PlacementCostError("Placement cost not written out correctly")

Also applies to: 323-323, 343-343, 367-367, 384-384, 401-401, 418-418

dev/pylint_check.py (1)

224-226: Consider documenting the rationale for 30 positional arguments.

While the PR description mentions that many files use 25+ positional arguments, setting the limit to 30 is quite high compared to typical best practices (5-7 arguments). This may hide legitimate code complexity issues.

Consider adding a comment explaining why this high limit is necessary and whether there's a plan to refactor functions with excessive parameters in the future:

🔎 Suggested documentation
 
         # Increase the max number of positional arguments.
+        # Many legacy functions in this codebase use 25+ positional arguments.
+        # TODO: Refactor these functions to use fewer parameters or configuration objects.
         cmd.append("--max-positional-arguments=30")
vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py (1)

452-453: Consider removing the pylint directive if .keys() is intentional.

The pylint: disable-next=consider-using-dict-items directive suppresses a warning about iterating over pass_requirements.keys(). Since only the keys are used in the loop (line 453), using .keys() is actually appropriate here and shouldn't trigger a warning. However, if this warning does appear with pylint 4.0.4, the directive is acceptable.

If the pylint warning is no longer triggered with the updated version, consider removing the directive:

🔎 Potential simplification
-        first_fail = True
-        # pylint: disable-next=consider-using-dict-items
-        for metric in pass_requirements.keys():
+        first_fail = True
+        for metric in pass_requirements.keys():

Alternatively, if the directive is needed, consider adding a comment explaining why:

         first_fail = True
+        # Only keys are needed here, not values
         # pylint: disable-next=consider-using-dict-items
         for metric in pass_requirements.keys():
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d176ea and 6f8a10a.

📒 Files selected for processing (37)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/test.yml (0 hunks)
  • dev/annealing_curve_plotter.py (0 hunks)
  • dev/external_subtrees.py (0 hunks)
  • dev/pylint_check.py (2 hunks)
  • dev/submit_slurm.py (0 hunks)
  • dev/vtr_test_suite_verifier/verify_test_suites.py (2 hunks)
  • doc/src/vtr_version.py (0 hunks)
  • odin_ii/regression_test/parse_result/conf/hooks.py (0 hunks)
  • odin_ii/regression_test/parse_result/parse_result.py (0 hunks)
  • odin_ii/regression_test/tools/odin_config_maker.py (0 hunks)
  • odin_ii/regression_test/tools/parse_odin_result.py (0 hunks)
  • requirements.txt (1 hunks)
  • run_reg_test.py (0 hunks)
  • vpr/scripts/compare_timing_reports.py (0 hunks)
  • vpr/scripts/profile/parse_and_plot_detailed.py (0 hunks)
  • vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened.py (2 hunks)
  • vtr_flow/scripts/arch_gen/arch_gen.py (0 hunks)
  • vtr_flow/scripts/benchtracker/flask_cors/core.py (0 hunks)
  • vtr_flow/scripts/benchtracker/interface_db.py (0 hunks)
  • vtr_flow/scripts/benchtracker/populate_db.py (0 hunks)
  • vtr_flow/scripts/blif_splicer.py (0 hunks)
  • vtr_flow/scripts/download_ispd.py (0 hunks)
  • vtr_flow/scripts/download_symbiflow.py (1 hunks)
  • vtr_flow/scripts/download_titan.py (0 hunks)
  • vtr_flow/scripts/ispd2vtr.py (0 hunks)
  • vtr_flow/scripts/noc/noc_benchmark_test.py (10 hunks)
  • vtr_flow/scripts/python_libs/vtr/log_parse.py (3 hunks)
  • vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py (1 hunks)
  • vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py (4 hunks)
  • vtr_flow/scripts/python_libs/vtr/task.py (1 hunks)
  • vtr_flow/scripts/python_libs/vtr/util.py (9 hunks)
  • vtr_flow/scripts/qor_compare.py (0 hunks)
  • vtr_flow/scripts/run_vtr_flow.py (3 hunks)
  • vtr_flow/scripts/run_vtr_task.py (3 hunks)
  • vtr_flow/scripts/tuning_runs/control_runs.py (2 hunks)
  • vtr_flow/scripts/upgrade_arch.py (0 hunks)
💤 Files with no reviewable changes (22)
  • odin_ii/regression_test/tools/odin_config_maker.py
  • dev/annealing_curve_plotter.py
  • .github/workflows/test.yml
  • vtr_flow/scripts/arch_gen/arch_gen.py
  • vtr_flow/scripts/download_ispd.py
  • vpr/scripts/compare_timing_reports.py
  • odin_ii/regression_test/parse_result/conf/hooks.py
  • vpr/scripts/profile/parse_and_plot_detailed.py
  • odin_ii/regression_test/parse_result/parse_result.py
  • dev/submit_slurm.py
  • vtr_flow/scripts/benchtracker/populate_db.py
  • vtr_flow/scripts/blif_splicer.py
  • vtr_flow/scripts/download_titan.py
  • dev/external_subtrees.py
  • run_reg_test.py
  • odin_ii/regression_test/tools/parse_odin_result.py
  • vtr_flow/scripts/benchtracker/flask_cors/core.py
  • vtr_flow/scripts/upgrade_arch.py
  • vtr_flow/scripts/benchtracker/interface_db.py
  • doc/src/vtr_version.py
  • vtr_flow/scripts/ispd2vtr.py
  • vtr_flow/scripts/qor_compare.py
🧰 Additional context used
🧬 Code graph analysis (1)
vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py (2)
vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py (1)
  • parse_vtr_flow (45-97)
vtr_flow/scripts/python_libs/vtr/task.py (4)
  • parse_command (166-170)
  • second_parse_command (172-176)
  • work_dir (184-188)
  • qor_parse_command (178-182)
🪛 Ruff (0.14.8)
vtr_flow/scripts/download_symbiflow.py

115-115: Audit URL open for permitted schemes. Allowing use of file: or custom schemes is often unexpected.

(S310)

vtr_flow/scripts/noc/noc_benchmark_test.py

299-299: Avoid specifying long messages outside the exception class

(TRY003)


323-323: Avoid specifying long messages outside the exception class

(TRY003)


343-343: Avoid specifying long messages outside the exception class

(TRY003)


367-367: Avoid specifying long messages outside the exception class

(TRY003)


384-384: Avoid specifying long messages outside the exception class

(TRY003)


401-401: Avoid specifying long messages outside the exception class

(TRY003)


418-418: Avoid specifying long messages outside the exception class

(TRY003)


535-535: subprocess call: check for execution of untrusted input

(S603)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: B: Clang 18 (Ubuntu Noble - 24.04)
  • GitHub Check: R: Strong
  • GitHub Check: B: GCC 14 (Ubuntu Noble - 24.04)
  • GitHub Check: R: SystemVerilog
  • GitHub Check: B: GCC 12 (Ubuntu Noble - 24.04)
  • GitHub Check: R: Valgrind Memory
  • GitHub Check: Ubuntu Jammy - 22.04 Compatibility Test
  • GitHub Check: Parmys Basic Test
  • GitHub Check: R: Strong_odin
  • GitHub Check: R: Valgrind Memory Odin
  • GitHub Check: ODIN-II Basic Test
  • GitHub Check: S: Basic
  • GitHub Check: B: Build Variations
  • GitHub Check: Image
🔇 Additional comments (24)
vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened.py (2)

18-18: LGTM! UTF-8 encoding standardization.

The explicit UTF-8 encoding improves cross-platform compatibility and follows best practices for file I/O operations.


30-44: LGTM! Consistent UTF-8 encoding across all file operations.

The explicit UTF-8 encoding for both reading and writing operations ensures consistent text handling across different platforms and follows Python best practices.

vtr_flow/scripts/tuning_runs/control_runs.py (1)

64-66: LGTM! Encoding standardization improves text handling.

The explicit UTF-8 encoding added to file operations ensures consistent text handling across different platforms and prevents potential encoding issues.

Also applies to: 244-244

dev/vtr_test_suite_verifier/verify_test_suites.py (1)

53-53: LGTM! Consistent encoding standardization.

Explicit UTF-8 encoding added to file operations aligns with the repository-wide standardization effort and ensures reliable text decoding.

Also applies to: 81-81

vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py (1)

36-36: LGTM! Encoding added for consistent text handling.

vtr_flow/scripts/run_vtr_flow.py (3)

509-509: LGTM! UTF-8 encoding added for reliable text decoding.


596-599: LGTM! KeyboardInterrupt handling simplified correctly.

Removing the unused error variable binding is appropriate since the exception isn't used in the handler.


800-800: LGTM! Variable initialization ensures it exists on all paths.

Initializing return_status = None at the start of the function ensures the variable is defined on all code paths, preventing potential UnboundLocalError.

vtr_flow/scripts/python_libs/vtr/log_parse.py (2)

10-10: LGTM! Simplified import is appropriate for modern Python.

The direct import of xml.etree.ElementTree is correct. The C-based cElementTree module was deprecated in Python 3.9+ and merged into ElementTree, so the conditional import is no longer necessary.


427-427: LGTM! UTF-8 encoding standardization.

Explicit UTF-8 encoding added to file operations ensures consistent text handling.

Also applies to: 526-526

vtr_flow/scripts/python_libs/vtr/util.py (3)

184-192: LGTM! Pylint directive is justified.

The consider-using-with directive is appropriately disabled here because the subprocess needs to be managed manually to read from stdout in a loop and handle timeouts. The comment about PWD environment variable is also helpful context.


266-266: LGTM! Comprehensive UTF-8 encoding standardization.

All file operations now explicitly specify UTF-8 encoding, ensuring consistent text handling across platforms.

Also applies to: 280-280, 303-303, 325-325, 361-361, 364-364, 385-385, 415-415


459-461: LGTM! More specific exception type improves error handling.

Raising FileNotFoundError instead of generic Exception is more specific and pythonic, making error handling clearer for callers.

vtr_flow/scripts/noc/noc_benchmark_test.py (3)

253-280: LGTM! Context manager and encoding improvements.

The use of a context manager ensures proper file closure, and explicit UTF-8 encoding standardizes text handling. The indentation adjustments maintain readability.


533-535: LGTM! Context manager usage is safer.

Using a context manager ensures the file is properly closed even if the subprocess fails.


632-639: LGTM! Context manager and encoding standardization.

vtr_flow/scripts/python_libs/vtr/task.py (1)

392-407: LGTM! Clean refactor to use max().

The refactor from conditional assignment to using max() is more concise and idiomatic. The logic remains functionally equivalent while improving readability.

dev/pylint_check.py (1)

211-214: LGTM! Updated ignored check for pylint 4.0.4.

The change from ignoring C0330 (bad-continuation) to C0209 (consider-using-f-string) aligns with the pylint version upgrade. The C0330 check was removed in newer pylint versions, and deferring f-string migration is a reasonable pragmatic choice for this PR.

vtr_flow/scripts/run_vtr_task.py (2)

408-411: LGTM! Proper UTF-8 encoding added for cross-platform compatibility.

Explicitly specifying encoding="utf-8" for file operations is good practice and ensures consistent behaviour across different platforms, particularly Windows where the default encoding can differ.


489-500: LGTM! Consistent UTF-8 encoding for log file operations.

The UTF-8 encoding specification is correctly applied to both write and read operations on the same file, ensuring consistency.

vtr_flow/scripts/python_libs/vtr/parse_vtr_task.py (2)

225-240: LGTM! UTF-8 encoding properly added to parse file operations.

The explicit UTF-8 encoding is correctly applied to all parse result file write operations, ensuring consistent Unicode handling across platforms.


252-264: LGTM! Consistent UTF-8 encoding for file I/O.

The encoding specification is properly applied to both read and write operations throughout the function.

.github/workflows/lint.yml (1)

30-45: LGTM! Well-structured Python linting CI job.

The new PythonLint job is properly configured with:

  • Appropriate runner (ubuntu-24.04) aligning with the PR's goal to support the newer Ubuntu version
  • Reasonable timeout (5 minutes)
  • Correct dependency installation from requirements.txt
  • Proper execution of the linting script

This successfully separates Python linting into a dedicated CI job.

requirements.txt (1)

10-10: Version 4.0.4 exists and is stable with no known critical security advisories.

Pylint 4.0.4 is available on PyPI and has been released with proper attestations. The upgrade from pylint 2.7.4 to 4.0.4 represents a legitimate version progression through stable releases. Based on comprehensive vulnerability database searches, no critical security advisories have been identified for pylint 4.0.4; historical vulnerabilities in earlier versions (2.5.0, 2.7.0) have long been remediated in this current release.

Comment on lines +115 to 117
with request.urlopen(url) as response:
latest_package_url = response.read().decode("utf-8")
print("Downloading latest package:\n{}".format(latest_package_url))
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, locate the file
find . -name "download_symbiflow.py" -type f

# Then verify BASE_URL and GCS_URL usage
rg -n "BASE_URL|GCS_URL" vtr_flow/scripts/download_symbiflow.py -A2

Repository: verilog-to-routing/vtr-verilog-to-routing

Length of output: 407


🏁 Script executed:

#!/bin/bash
# Check for any hardcoded URLs in the file
rg -n "http|file:|url" vtr_flow/scripts/download_symbiflow.py -i

Repository: verilog-to-routing/vtr-verilog-to-routing

Length of output: 1248


🏁 Script executed:

#!/bin/bash
# Read the context around lines 115-117 and related URL construction
cat -n vtr_flow/scripts/download_symbiflow.py | head -120 | tail -30

Repository: verilog-to-routing/vtr-verilog-to-routing

Length of output: 1443


Good improvement to use context manager for resource safety.

The switch to a context manager ensures proper resource cleanup. The .decode("utf-8") is also explicit and correct. All hardcoded URL constants (BASE_URL and GCS_URL) use HTTPS schemes.

However, the latest_package_url read from the response on line 116 is used directly with request.urlretrieve() on line 118 without validating its scheme. Consider validating that the URL from the response uses HTTPS before retrieval to prevent potential attacks through response manipulation.

🧰 Tools
🪛 Ruff (0.14.8)

115-115: Audit URL open for permitted schemes. Allowing use of file: or custom schemes is often unexpected.

(S310)

🤖 Prompt for AI Agents
In vtr_flow/scripts/download_symbiflow.py around lines 115 to 117, the
latest_package_url read from the HTTP response is used directly later; validate
that the returned URL uses HTTPS before calling request.urlretrieve(). Parse the
latest_package_url (trim whitespace/newlines), use urllib.parse.urlparse to
check parsed.scheme == "https" (or explicitly fail if not), and on failure log
an error and exit/raise to avoid following non-HTTPS URLs. Ensure the validation
happens immediately after decoding the response and before any download
attempts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation infra Project Infrastructure lang-python Python code Odin Odin II Logic Synthesis Tool: Unsorted item scripts Utility & Infrastructure scripts tests VPR VPR FPGA Placement & Routing Tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants