JelleZijlstra / typeshed_client

Retrieve information from typeshed and other typing stubs
MIT License
20 stars 2 forks source link

Use Ruff, fix various tests #92

Closed JelleZijlstra closed 7 months ago

AlexWaygood commented 7 months ago

You could consider adding RUF021, since you suggested it ;)

But it's still in preview, so I think you'd have to add preview = true to tool.ruff.lint in your pyproject.toml

JelleZijlstra commented 7 months ago

I added the whole RUF series because why not. I really like RUF005; that's something I've often done manually.

JelleZijlstra commented 7 months ago

Though come to think of it I should probably refactor that code that RUF005 changed since it deals with the old typeshed layout.

AlexWaygood commented 7 months ago

I added the whole RUF series because why not. I really like RUF005; that's something I've often done manually.

Funny, that's one of only two RUF one I have disabled in my config for typeshed-stats 😄 I'm not sure it always leads to faster code. But YMMV :)

The other RUF one I disable is RUF013 (because mypy already enforces that), and I disable the autofix for RUF017 (ruff chooses the fastest autofix, which uses functools.reduce and operator.iadd, but I prefer itertools.chain.from_iterable, which is only a tiny bit slower and looks much cleaner IMO)

JelleZijlstra commented 7 months ago

As for RUF005, I don't really care if it's marginally faster (if it's slower, just complain to Brandt :P), but I feel it makes the code look cleaner.

What's the disadvantage in having RUF013 on even if mypy also enforces it?

AlexWaygood commented 7 months ago

What's the disadvantage in having RUF013 on even if mypy also enforces it?

No real disadvantage, just my personal preference -- I just prefer to have the type checker complain about my types and ruff focus on other stuff :)