typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Enable more Ruff PYI rules with autofixes

Open Avasam opened this issue 1 year ago • 2 comments

Added rules: PYI014, PYI015, PYI030, PYI036, PYI044, PYI062

I originally split this into 3 sections (Fix is always available., Fix is sometimes available., and We sometimes noqa these), but I'm not sure if that's something worth doing, keeping it here for archiving purposes:

select = [
    ...

	# PYI rules that sometimes autofix, but we should always be able to manually fix,
	# so there's still no conflict/duplicate with flake8-pyi
	"PYI013", # Non-empty class bodies must not contain `...`
	"PYI016", # Duplicate union member `{}`
	"PYI025", # Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin
	"PYI030", # Multiple literal members in a union. Use a single literal, e.g. `Literal[{}]`
	"PYI036", # Star-args in `{method_name}` should be annotated with `object`
	"PYI044", # `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics
	"PYI055", # Multiple `type[T]` usages in a union. Combine them into one, e.g., `type[{union_str}]`.
	"PYI062", # Duplicate literal member `{}`
	# Rules that have autofixes, but we sometimes disable on a per-line basis
	# "PYI026", Waiting for this mypy bug to be fixed: https://github.com/python/mypy/issues/16581
	# "PYI029", __str__ and __str__ sometimes have to be used for classes other than `object`
	# Sometimes we still wanna be explicit about a default value nonetheless
	# "PYI011",
	# "PYI053", Also removes `Literal[{string_too_long}]` from an annotation
	# "PYI054",
]

Avasam avatar Aug 19 '24 17:08 Avasam

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Aug 19 '24 17:08 github-actions[bot]

Doesn't look like Ruff 0.6.2 added anything that should affect this (PYI053 has less false-positives, but it's still disabled on our side)

Avasam avatar Aug 22 '24 19:08 Avasam

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Sep 04 '24 23:09 github-actions[bot]

Jelle approved 2 weeks ago and it's unchallenged. I'll merge it. If you see an issue, open a new PR!

Avasam avatar Sep 04 '24 23:09 Avasam