Skip to content

Conversation

@ntBre
Copy link
Contributor

@ntBre ntBre commented Jan 26, 2026

Summary

I was initially just debugging astral-sh/ruff-action#307 with Claude and was quite skeptical when it started rewriting the is-wsl crate, but after taking a closer look at is-wsl and its dependency is-docker, I thought it might actually be worth doing.

This PR fixes astral-sh/ruff-action#307 by essentially inlining both the is-wsl and is-docker crates and expanding the is_docker check to account for additional types of containers. These crates are both one-file dependencies that haven't been updated in a couple of years.

As shown in the debug logs from my comment on the issue, the minimal change to resolve the problem for the ubuntu-slim GitHub runner is to check for /run/.containerenv in addition to /.dockerenv, but Claude added a few additional checks on the cgroup to cover LXC and kubernetes containers too.

Test Plan

I forked the reproduction repo shared in the issue and tested that the Ruff version on this branch produces an EXE001 diagnostic, as expected: brentbot/my-ruff-issue#1

image

Summary
--

I was initially just debugging astral-sh/ruff-action#307 with Claude and was
quite skeptical when it started rewriting the [`is-wsl`] crate, but after taking
a closer look at `is-wsl` and its dependency [`is-docker`], I thought it might
actually be worth doing.

This PR fixes astral-sh/ruff-action#307 by essentially inlining both the
`is-wsl` and `is-docker` crates and expanding the `is_docker` check to account
for additional types of containers. These crates are both one-file dependencies
that haven't been updated in a couple of years.

As shown in the debug logs from my comment on the issue, the minimal change to
resolve the problem for the `ubuntu-slim` GitHub runner is to check for
`/run/.containerenv` in addition to `/.dockerenv`, but Claude added a few
additional checks on the `cgroup` to cover LXC and kubernetes containers too.

Test Plan
--

I forked the reproduction repo shared in the issue and tested that the Ruff
version on this branch produces an `EXE001` diagnostic, as expected:
brentbot/my-ruff-issue#1

[`is-wsl`]: https://github.com/TheLarkInn/is-wsl/blob/main/src/lib.rs
[`is-docker`]: https://github.com/TheLarkInn/is-docker/blob/main/src/lib.rs
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 26, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 26, 2026

mypy_primer results

Changes were detected when running on open source projects
prefect (https://github.com/PrefectHQ/prefect)
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:94:28: error[invalid-assignment] Object of type `dict[str, Any] | int | dict[Any, Any] | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/integrations/prefect-dbt/prefect_dbt/core/settings.py:99:28: error[invalid-assignment] Object of type `int | dict[Any, Any] | float | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_core.py:86:21: error[invalid-assignment] Object of type `dict[str, Any] | int | dict[Any, Any] | ... omitted 4 union elements` is not assignable to `dict[str, Any]`
- src/prefect/cli/deploy/_core.py:87:21: error[invalid-assignment] Object of type `int | dict[Any, Any] | float | ... omitted 3 union elements` is not assignable to `dict[str, Any]`
- src/prefect/deployments/steps/core.py:137:38: error[invalid-argument-type] Argument is incorrect: Argument type `dict[str, Any] | int | dict[Any, Any] | ... omitted 4 union elements` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `dict[str, Any] | int | Unknown | ... omitted 4 union elements` on object of type `dict[str, Any]`
+ src/prefect/utilities/templating.py:320:13: error[invalid-assignment] Invalid subscript assignment with key of type `object` and value of type `Unknown | dict[str, Any]` on object of type `dict[str, Any]`
- src/prefect/utilities/templating.py:323:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_block_document_references | dict[str, Any]`, found `list[Unknown | dict[str, Any] | int | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:323:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_block_document_references | dict[str, Any]`, found `list[Unknown | dict[str, Any]]`
- src/prefect/utilities/templating.py:437:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, Unknown | int | float | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:437:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `dict[object, Unknown]`
- src/prefect/utilities/templating.py:442:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `list[Unknown | int | float | ... omitted 4 union elements]`
+ src/prefect/utilities/templating.py:442:16: error[invalid-return-type] Return type does not match returned value: expected `T@resolve_variables`, found `list[Unknown]`
+ src/prefect/workers/base.py:232:13: error[invalid-argument-type] Argument is incorrect: Argument type `str | dict[str, Any]` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/workers/base.py:232:13: error[invalid-argument-type] Argument is incorrect: Argument type `dict[str, Any] | int | str | ... omitted 3 union elements` does not satisfy constraints (`str`, `int`, `int | float`, `bool`, `dict[Any, Any]`, `list[Any]`, `None`) of type variable `T`
- src/prefect/workers/base.py:234:20: error[invalid-argument-type] Argument expression after ** must be a mapping type: Found `int | Unknown | float | ... omitted 4 union elements`
- Found 5365 diagnostics
+ Found 5359 diagnostics

core (https://github.com/home-assistant/core)
+ homeassistant/util/variance.py:47:12: error[invalid-return-type] Return type does not match returned value: expected `(**_P@ignore_variance) -> _R@ignore_variance`, found `_Wrapped[_P@ignore_variance, int | _R@ignore_variance | float | datetime, _P@ignore_variance, _R@ignore_variance | int | float | datetime]`
- Found 14494 diagnostics
+ Found 14495 diagnostics

No memory usage changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 26, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@ntBre ntBre added the rule Implementing or modifying a lint rule label Jan 27, 2026
@ntBre ntBre marked this pull request as ready for review January 27, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

action on ubuntu-slim runner disables EXE001

2 participants