Skip to content

chore(ruff): enable four low-risk checks - #10586

Merged
dmadisetti merged 4 commits into
mainfrom
t3code/enable-safe-ruff-rules
Aug 20, 2026
Merged

chore(ruff): enable four low-risk checks#10586
dmadisetti merged 4 commits into
mainfrom
t3code/enable-safe-ruff-rules

Conversation

@Light2Dark

@Light2Dark Light2Dark commented Aug 19, 2026

Copy link
Copy Markdown
Member

This pull request was authored by a coding agent.

Ruff still globally suppresses several checks whose remaining violations are small and mechanical. This enables PLW1508, UP045, PYI066, and PLW0602 while preserving the two intentional runtime patterns with narrow inline exceptions.

The changes keep behavior stable: environment defaults remain integers after parsing, Python compatibility imports retain the same version split, and explicit notebook global lookup remains covered by its scoping test.

Written by gpt-5.6-sol on Codex

@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview Aug 20, 2026 4:56am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Light2Dark Light2Dark added the internal A refactor or improvement that is not user facing label Aug 19, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 8 files

Architecture diagram
sequenceDiagram
    participant Config as Config Module
    participant Env as Environment Variables
    participant TypeSystem as Type System
    participant VersionCheck as Python Version Check
    participant OpenAPI as OpenAPI Converter
    participant Runtime as Runtime Context
    participant CacheTest as Cache Test

    Note over Config,Env: Configuration defaults handling

    Config->>VersionCheck: Check sys.version_info
    alt Python >= 3.11
        Config->>TypeSystem: Import NotRequired from typing
    else Python < 3.11
        Config->>TypeSystem: Import NotRequired from typing_extensions
    end

    Config->>Env: Read MARIMO_OUTPUT_MAX_BYTES
    Env-->>Config: String value or "8000000" default
    Config->>Config: Convert to int

    Config->>Env: Read MARIMO_STD_STREAM_MAX_BYTES
    Env-->>Config: String value or "1000000" default
    Config->>Config: Convert to int

    Note over OpenAPI,TypeSystem: Optional type construction

    OpenAPI->>VersionCheck: Check sys.version_info
    alt Python >= 3.11
        OpenAPI->>TypeSystem: Import NotRequired from typing
    else Python < 3.11
        OpenAPI->>TypeSystem: Import NotRequired from typing_extensions
    end

    OpenAPI->>OpenAPI: Build optional_name_overrides dict
    Note right of OpenAPI: Uses Optional[arg] at runtime<br/>with intentional suppression

    Note over Runtime: Thread-local context management

    Runtime->>Runtime: install() context manager
    Runtime->>Runtime: Access _THREAD_LOCAL_CONTEXT directly
    Runtime->>Runtime: Save and restore old context

    Runtime->>Runtime: initialize_context()
    Runtime->>Runtime: Access _THREAD_LOCAL_CONTEXT directly
    Runtime->>Runtime: Initialize runtime context

    Runtime->>Runtime: teardown_context()
    Runtime->>Runtime: Access _THREAD_LOCAL_CONTEXT directly
    Runtime->>Runtime: Clear runtime context

    Note over CacheTest: Global variable behavior test

    CacheTest->>CacheTest: Define function with global state
    CacheTest->>CacheTest: Explicit global lookup
    Note right of CacheTest: Intentional pattern with<br/>scoping test coverage
Loading

Re-trigger cubic

@Light2Dark
Light2Dark marked this pull request as ready for review August 19, 2026 05:58
Copilot AI lite review requested due to automatic review settings August 19, 2026 05:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens marimo’s Ruff configuration by enabling four previously-ignored, low-risk rules and makes small, targeted code changes to satisfy them without altering runtime behavior.

Changes:

  • Enables Ruff checks PLW1508, UP045, PYI066, and PLW0602 by removing them from the global ignore list.
  • Reorders sys.version_info branches so the newer-Python import path is first (PYI066), across runtime code and tests.
  • Addresses two intentional runtime patterns with narrow inline exceptions (global lookup test + runtime Optional[...] construction), and fixes env-var defaults to be strings before int(...) conversion (PLW1508).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Removes ignores for the four Ruff rules to enable them repository-wide.
marimo/_config/config.py Fixes os.getenv defaults to be strings before parsing to int (PLW1508) and updates version-branch ordering for NotRequired.
marimo/_utils/parse_dataclass.py Updates NotRequired import branching to put newer Python first (PYI066).
marimo/_utils/dataclass_to_openapi.py Updates NotRequired import branching (PYI066) and adds a targeted UP045 inline exemption for runtime Optional[...] construction.
marimo/_utils/narwhals_utils.py Simplifies TypeGuard import by removing redundant version branching.
marimo/_runtime/context/types.py Removes unnecessary global declarations where no global assignment occurs (PLW0602).
tests/_utils/test_parse_dataclass.py Mirrors NotRequired import branch ordering change for PYI066.
tests/_save/test_cache.py Adds a targeted PLW0602 inline exemption to preserve an intentional “global lookup” test pattern.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Light2Dark
Light2Dark requested a review from dmadisetti August 19, 2026 06:38
@dmadisetti
dmadisetti merged commit 4e4efcc into main Aug 20, 2026
52 checks passed
@dmadisetti
dmadisetti deleted the t3code/enable-safe-ruff-rules branch August 20, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants