Skip to content

Commit

Permalink
chore(python): Address Ruff per file ignores (#10258)
Browse files Browse the repository at this point in the history
Co-authored-by: Stijn de Gooijer <stijn@degooijer.io>
  • Loading branch information
zundertj and stinodego authored Aug 10, 2023
1 parent 1494033 commit 64adbec
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion py-polars/polars/utils/show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def show_versions() -> None:
"""
r"""
Print out version of Polars and dependencies to stdout.
Examples
Expand Down
29 changes: 22 additions & 7 deletions py-polars/polars/utils/udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@
from inspect import signature
from itertools import count, zip_longest
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Iterator, Literal, NamedTuple, Union
from typing import (
TYPE_CHECKING,
Any,
Callable,
ClassVar,
Iterator,
Literal,
NamedTuple,
Union,
)

if TYPE_CHECKING:
from dis import Instruction
Expand All @@ -37,7 +46,7 @@ class StackValue(NamedTuple):


class OpNames:
BINARY = {
BINARY: ClassVar[dict[str, str]] = {
"BINARY_ADD": "+",
"BINARY_AND": "&",
"BINARY_FLOOR_DIVIDE": "//",
Expand All @@ -49,8 +58,11 @@ class OpNames:
"BINARY_TRUE_DIVIDE": "/",
"BINARY_XOR": "^",
}
CALL = {"CALL"} if _MIN_PY311 else {"CALL_FUNCTION", "CALL_METHOD"}
CONTROL_FLOW = (

CALL: ClassVar[set[str]] = (
{"CALL"} if _MIN_PY311 else {"CALL_FUNCTION", "CALL_METHOD"}
)
CONTROL_FLOW: ClassVar[dict[str, str]] = (
{
"POP_JUMP_FORWARD_IF_FALSE": "&",
"POP_JUMP_FORWARD_IF_TRUE": "|",
Expand All @@ -66,16 +78,19 @@ class OpNames:
}
)
LOAD_VALUES = frozenset(("LOAD_CONST", "LOAD_DEREF", "LOAD_FAST", "LOAD_GLOBAL"))
LOAD_ATTR = {"LOAD_METHOD", "LOAD_ATTR"} if _MIN_PY311 else {"LOAD_METHOD"}
LOAD_ATTR: ClassVar[set[str]] = (
{"LOAD_METHOD", "LOAD_ATTR"} if _MIN_PY311 else {"LOAD_METHOD"}
)
LOAD = LOAD_VALUES | {"LOAD_METHOD", "LOAD_ATTR"}
SYNTHETIC = {
SYNTHETIC: ClassVar[dict[str, int]] = {
"POLARS_EXPRESSION": 1,
}
UNARY = {
UNARY: ClassVar[dict[str, str]] = {
"UNARY_NEGATIVE": "-",
"UNARY_POSITIVE": "+",
"UNARY_NOT": "~",
}

PARSEABLE_OPS = (
{"BINARY_OP", "BINARY_SUBSCR", "COMPARE_OP", "CONTAINS_OP", "IS_OP"}
| set(UNARY)
Expand Down
3 changes: 0 additions & 3 deletions py-polars/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ ban-relative-imports = "all"
strict = true

[tool.ruff.per-file-ignores]
"polars/datatypes.py" = ["B019"]
"tests/**/*.py" = ["D100", "D103", "B018"]
"polars/utils/show_versions.py" = ["D301"]
"polars/utils/udfs.py" = ["RUF012"]

[tool.pytest.ini_options]
addopts = [
Expand Down
1 change: 0 additions & 1 deletion py-polars/tests/unit/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,6 @@ def test_describe() -> None:
date_s = pl.Series([date(2021, 1, 1), date(2021, 1, 2), date(2021, 1, 3)])
empty_s = pl.Series(np.empty(0))

pl.DataFrame
assert dict(num_s.describe().rows()) == { # type: ignore[arg-type]
"count": 3.0,
"mean": 2.0,
Expand Down

0 comments on commit 64adbec

Please sign in to comment.