Skip to content

Commit

Permalink
chore(python): Address Ruff per file ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Aug 9, 2023
1 parent 1494033 commit 7b4261a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 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
47 changes: 27 additions & 20 deletions py-polars/polars/utils/udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from inspect import signature
from itertools import count, zip_longest
from pathlib import Path
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Callable, Iterator, Literal, NamedTuple, Union

if TYPE_CHECKING:
Expand All @@ -37,18 +38,20 @@ class StackValue(NamedTuple):


class OpNames:
BINARY = {
"BINARY_ADD": "+",
"BINARY_AND": "&",
"BINARY_FLOOR_DIVIDE": "//",
"BINARY_MODULO": "%",
"BINARY_MULTIPLY": "*",
"BINARY_OR": "|",
"BINARY_POWER": "**",
"BINARY_SUBTRACT": "-",
"BINARY_TRUE_DIVIDE": "/",
"BINARY_XOR": "^",
}
BINARY = MappingProxyType(
{
"BINARY_ADD": "+",
"BINARY_AND": "&",
"BINARY_FLOOR_DIVIDE": "//",
"BINARY_MODULO": "%",
"BINARY_MULTIPLY": "*",
"BINARY_OR": "|",
"BINARY_POWER": "**",
"BINARY_SUBTRACT": "-",
"BINARY_TRUE_DIVIDE": "/",
"BINARY_XOR": "^",
}
)
CALL = {"CALL"} if _MIN_PY311 else {"CALL_FUNCTION", "CALL_METHOD"}
CONTROL_FLOW = (
{
Expand All @@ -68,14 +71,18 @@ 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 = LOAD_VALUES | {"LOAD_METHOD", "LOAD_ATTR"}
SYNTHETIC = {
"POLARS_EXPRESSION": 1,
}
UNARY = {
"UNARY_NEGATIVE": "-",
"UNARY_POSITIVE": "+",
"UNARY_NOT": "~",
}
SYNTHETIC = MappingProxyType(
{
"POLARS_EXPRESSION": 1,
}
)
UNARY = MappingProxyType(
{
"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 7b4261a

Please sign in to comment.