Skip to content

Commit

Permalink
match on both
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Aug 5, 2023
1 parent 68efb5f commit 73ee469
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 1 addition & 7 deletions py-polars/polars/utils/udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ class StackValue(NamedTuple):
StackEntry: TypeAlias = Union[str, StackValue]

_MIN_PY311 = sys.version_info >= (3, 11)
try:
get_ipython # type: ignore[name-defined] # noqa: B018
except NameError:
_IN_IPYTHON = False
else:
_IN_IPYTHON = True


class OpNames:
Expand Down Expand Up @@ -72,7 +66,7 @@ class OpNames:
}
)
LOAD_VALUES = frozenset(("LOAD_CONST", "LOAD_DEREF", "LOAD_FAST", "LOAD_GLOBAL"))
LOAD_ATTR = {"LOAD_ATTR"} if (_MIN_PY311 and not _IN_IPYTHON) else {"LOAD_METHOD"}
LOAD_ATTR = {"LOAD_METHOD", "LOAD_ATTR"} if _MIN_PY311 else {"LOAD_METHOD"}
LOAD = LOAD_VALUES | {"LOAD_METHOD", "LOAD_ATTR"}
SYNTHETIC = {
"POLARS_EXPRESSION": 1,
Expand Down
2 changes: 2 additions & 0 deletions py-polars/tests/test_udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def test_bytecode_parser_expression_in_ipython(

script = (
"import udfs; "
"import numpy as np; "
"import json; "
f"MY_DICT = {MY_DICT};"
f'bytecode_parser = udfs.BytecodeParser({func}, apply_target="expr");'
f'print(bytecode_parser.to_expression("{col}"));'
Expand Down

0 comments on commit 73ee469

Please sign in to comment.