Skip to content

ruff 0.0.284 #54548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2023
Merged

ruff 0.0.284 #54548

merged 3 commits into from
Aug 15, 2023

Conversation

twoertwein
Copy link
Member

Ruff enabled many of the flake8-pyi rules for py files.

return result
# error: Incompatible return value type (got "MultiIndex",
# expected "Self")
return result # type: ignore[return-value]
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why mypy didn't find this previously: self == other can return an ExtensionArray and it seems that it doesn't define __invert__

)

from pandas import DataFrame


class ReaderBase(Protocol):
class ReaderBase(ABC):
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this should be an abstract class and not a protocol.

@@ -211,6 +211,7 @@ line-length = 88
target-version = "py310"
fix = true
unfixable = []
typing-modules = ["pandas._typing"]
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed for ruff to know that pandas._typing.Self is the same as typing.Self

@@ -303,16 +304,14 @@ ignore = [
"PLW0603",
# Docstrings should not be included in stubs
"PYI021",
# Use `typing.NamedTuple` instead of `collections.namedtuple`
"PYI024",
Copy link
Member Author

Choose a reason for hiding this comment

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

I assume that there might be objections against enabling this rule as it might(?) affect runtime a tiny bit. Could move it to the todo list if there are no objections (currently in the ignore list).

Copy link
Member

Choose a reason for hiding this comment

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

Would the runtime be present in the importing of NamedTuple? I would have thought that would be protected in if TYPE_CHECKING?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe it would have runtime implications (but they are likely to be neglectable) as you have to define a class that is used at runtime https://docs.python.org/3/library/typing.html#typing.NamedTuple

# Use typing_extensions.TypeAlias for type aliases
# "PYI026", # not yet implemented
# Use "collections.abc.*" instead of "typing.*" (PEP 585 syntax)
# "PYI027", # not yet implemented
Copy link
Member Author

Choose a reason for hiding this comment

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

They are now implemented but they also did not require any changes.

@twoertwein twoertwein marked this pull request as ready for review August 15, 2023 13:57
@mroeschke mroeschke added the Code Style Code style, linting, code_checks label Aug 15, 2023
@mroeschke mroeschke added this to the 2.2 milestone Aug 15, 2023
@mroeschke mroeschke merged commit 3e562dd into pandas-dev:main Aug 15, 2023
@mroeschke
Copy link
Member

Thanks @twoertwein

mroeschke pushed a commit to mroeschke/pandas that referenced this pull request Aug 18, 2023
* ruff 0.0.284

* fix strict type check

* missing space
@twoertwein twoertwein deleted the ruff branch September 19, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants