Skip to content

Add --unsafe#85

Merged
MarcoGorelli merged 2 commits intoMarcoGorelli:mainfrom
akx:unsafe-mode
Feb 2, 2026
Merged

Add --unsafe#85
MarcoGorelli merged 2 commits intoMarcoGorelli:mainfrom
akx:unsafe-mode

Conversation

@akx
Copy link
Contributor

@akx akx commented Nov 3, 2025

Applies transformations that might be wrong and need human eyes to verify.

Right now this means looking at assignments etc. also within sub-scopes, and we can't currently verify whether those are "safe".

@MarcoGorelli
Copy link
Owner

thanks for your prs - have you considered upstreaming this (together with improvements) to ruff?

@akx
Copy link
Contributor Author

akx commented Nov 3, 2025

An example of unsafeness:

def unique_truthy_in_order(iterable):
    seen = set()
    for item in iterable:
        if not item:
            continue
        if item not in seen:
            yield item
            seen.add(item)

👇

def unique_truthy_in_order(iterable):
    for item in iterable:
        if not item:
            continue
        if item not in (seen := set()):
            yield item
            seen.add(item)

@akx
Copy link
Contributor Author

akx commented Nov 3, 2025

thanks for your prs - have you considered upstreaming this (together with improvements) to ruff?

I've contributed some things to Ruff 😄

It's just a whole lot more involved than adding a couple of simple fixes in a small Python repo like this.

@MarcoGorelli
Copy link
Owner

thanks - could you ask them if they'd be interested in doing what auto-walrus does?

because if ruff ends up doing this anyway, then i wouldn't be particularly motivated to spend time on it

@akx
Copy link
Contributor Author

akx commented Nov 5, 2025

Well, there was no definite interest there (see link above).

@akx
Copy link
Contributor Author

akx commented Jan 16, 2026

So WDYT, could these PRs get merged in anyway, even if Ruff isn't currently moving to walrusing?

@MarcoGorelli
Copy link
Owner

pre-commit-ci is failing

Copy link
Owner

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

thanks @akx !

@MarcoGorelli MarcoGorelli merged commit efa4898 into MarcoGorelli:main Feb 2, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments