-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
STYLE ruff: enable PIE #51434
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
STYLE ruff: enable PIE #51434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for working on this!
.pre-commit-config.yaml
Outdated
@@ -19,6 +19,7 @@ repos: | |||
rev: v0.0.244 | |||
hooks: | |||
- id: ruff | |||
args: [--fix, --exit-non-zero-on-fix] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not add this please? there's a few false positives which risk confusing contributors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Would remove it.
@@ -836,8 +836,6 @@ def view(self, dtype: Dtype | None = None) -> Series: | |||
|
|||
# ---------------------------------------------------------------------- | |||
# NDArray Compat | |||
_HANDLED_TYPES = (Index, ExtensionArray, np.ndarray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error was PIE794. The fix that was suggested was removing one of the instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah you're right, it is indeed duplicated. thanks!
@@ -875,7 +875,6 @@ class StataMissingValue: | |||
float32_base = struct.pack("<i", int_value) | |||
|
|||
float64_base: bytes = b"\x00\x00\x00\x00\x00\x00\xe0\x7f" | |||
increment = struct.unpack("q", b"\x00\x00\x00\x00\x00\x01\x00\x00")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error was PIE794. The fix that was suggested was removing one of the instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks - I don't think we can remove it though
can you rename the first one to increment_32
and the second one to increment_64
please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have corrected this.
doc/source/user_guide/style.ipynb
Outdated
@@ -47,6 +47,7 @@ | |||
"outputs": [], | |||
"source": [ | |||
"import matplotlib.pyplot\n", | |||
"\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did this file change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happened after I formatted using black by running:
black .
in bash.
It seems like it would be better if I put the reasons behind my changes in the description. Would do that next time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries - let's revert this, CI isn't running black-jupyter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you run black via pre-commit run black --all-files
then that'll match what's in CI
Removed the fix arguments.
@MarcoGorelli |
hey - I'd suggest looking at https://opensource.com/article/20/4/git-merge-conflict for how to resolve conflicts |
looks like you managed, nice! just need to revert changes to doc/source/user_guide/style.ipynb, if you do something like
it should work |
@MarcoGorelli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, looks good to me pending green
@MarcoGorelli |
pandas/io/formats/css.py
Outdated
CSS_EXPANSIONS = { | ||
**{ | ||
{ | ||
(f"border-{prop}" if prop else "border"): _border_expander(prop) | ||
for prop in ["", "top", "right", "bottom", "left"] | ||
}, | ||
**{ | ||
{ | ||
f"border-{prop}": _side_expander(f"border-{{:s}}-{prop}") | ||
for prop in ["color", "style", "width"] | ||
}, | ||
**{ | ||
{ | ||
"margin": _side_expander("margin-{:s}"), | ||
"padding": _side_expander("padding-{:s}"), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this one is causing some test failures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want
CSS_EXPANSIONS = {
**{
(f"border-{prop}" if prop else "border"): _border_expander(prop)
for prop in ["", "top", "right", "bottom", "left"]
},
**{
f"border-{prop}": _side_expander(f"border-{{:s}}-{prop}")
for prop in ["color", "style", "width"]
},
"margin": _side_expander("margin-{:s}"),
"padding": _side_expander("padding-{:s}"),
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the PIE error that was generated.
when it's ready, we will merge it - but first, the errors need fixing up |
@MarcoGorelli Sorry, I have been away for a while. I have re-run and I still see the errors. Looking through to see where I might have gone wrong. |
"column_dtypes": DictLike(**{"A": np.int8, "B": np.float32}), | ||
"column_dtypes": DictLike({"A": np.int8, "B": np.float32}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't right, you want
"column_dtypes": DictLike(A=np.int8, B=np.float32),
you can run this test with
pytest pandas/tests/frame/methods/test_to_records.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running pytest command is giving:
ImportError while loading conftest 'C:\Users\Victor Momodu\Documents\Programming\Data Science\Code\pandas\pandas\conftest.py'.
pandas\__init__.py:22: in <module>
from pandas.compat import is_numpy_dev as _is_numpy_dev # pyright: ignore # noqa:F401
pandas\compat\__init__.py:25: in <module>
from pandas.compat.numpy import (
pandas\compat\numpy\__init__.py:4: in <module>
from pandas.util.version import Version
pandas\util\__init__.py:2: in <module>
from pandas.util._decorators import ( # noqa:F401
pandas\util\_decorators.py:14: in <module>
from pandas._libs.properties import cache_readonly
pandas\_libs\__init__.py:13: in <module>
from pandas._libs.interval import Interval
E ModuleNotFoundError: No module named 'pandas._libs.interval'
I have checked the module that was said to be missing and it exists. I searched and found this.
I have made the required change and will be pushing it to remote.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to follow the instructions here to run tests https://pandas.pydata.org/docs/dev/development/contributing_environment.html
no worries :) I've suggested a couple of fixes, the rest looks good! |
Changed dtype_mappings and CSS_EXPANSIONS respectively.
Ran black pre-commit hook.
@MarcoGorelli All tests passed. I guess merging can now be done. |
yup, should be good, I'll just wait for a few more jobs to finish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @victorian177 !
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.