Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Oct 8, 2024
1 parent 4e351b3 commit 24952b3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- windows-latest
- macos-latest
python-version:
- "3.9"
- "3.10"
- "3.12"
steps:
- name: Checkout
Expand Down
21 changes: 16 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,20 @@ requires = ["poetry-core>=1.3.0"]

[tool.ruff]
fix = true
lint.ignore = [
# Line length — black handles
"E5", #
# No lambdas — too strict
"E731",
[tool.ruff.lint]
# E402: module level import not at top of file
# E501: line too long - let black worry about that
# E731: do not assign a lambda expression, use a def
extend-safe-fixes = [
"TID252", # absolute imports
]
ignore = ["E402", "E501", "E731", "UP007"]
extend-select = [
"B", # flake8-bugbear
"F", # Pyflakes
"E", # Pycodestyle
"W",
"TID", # flake8-tidy-imports (absolute imports)
"I", # isort
"UP", # Pyupgrade
]
7 changes: 4 additions & 3 deletions pyprql/magic/prql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

from __future__ import annotations

import re

from IPython.core.magic import cell_magic, line_magic, magics_class, needs_local_scope
from IPython.core.magic_arguments import argument, magic_arguments, parse_argstring
from prqlc import compile, CompileOptions
from prqlc import CompileOptions, compile
from sql.magic import SqlMagic
from sql.parse import parse
from traitlets import Bool, Unicode
import re


@magics_class
Expand Down Expand Up @@ -110,7 +111,7 @@ def prql(
_pattern = re.sub(r"\\\s", r"\\s+", _escaped_prql)
line = re.sub(_pattern, "", line)
if self.args.file:
with open(self.args.file, "r") as infile:
with open(self.args.file) as infile:
cell = infile.read()
line = re.sub(r"(\-f|\-\-file)\s+" + self.args.file, "", line)
# If cell is occupied, parsed to SQL
Expand Down
8 changes: 4 additions & 4 deletions pyprql/polars_namespace/prql.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations
import polars as pl
import prqlc

from typing import TypeVar, Generic
from typing import Generic, TypeVar

import polars as pl
import prqlc

T_DF = TypeVar("T_DF", pl.DataFrame, pl.LazyFrame)

Expand All @@ -12,7 +12,7 @@
@pl.api.register_lazyframe_namespace("prql")
class PrqlNamespace(Generic[T_DF]):
def __init__(self, df: T_DF):
self._df = df
self._df: T_DF = df

def query(self, prql_query: str, *, table_name: str | None = None) -> T_DF:
prepended_query: str = f"from self \n {prql_query}"
Expand Down
4 changes: 2 additions & 2 deletions pyprql/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ def run_sql(ip_session: "IPython.core.interactiveshell.InteractiveShell", statem
if isinstance(statements, str):
statements = [statements]
for statement in statements:
result = ip_session.run_line_magic("sql", "sqlite:// %s" % statement)
result = ip_session.run_line_magic("sql", f"sqlite:// {statement}")
return result # returns only last result


def run_prql(ip_session: "IPython.core.interactiveshell.InteractiveShell", statements):
if isinstance(statements, str):
statements = [statements]
for statement in statements:
result = ip_session.run_line_magic("prql", "sqlite:// %s" % statement)
result = ip_session.run_line_magic("prql", f"sqlite:// {statement}")
return result # returns only last result
3 changes: 1 addition & 2 deletions pyprql/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from pathlib import Path

import pytest
from sql import connection
from sql import _current
from sql import _current, connection
from sql._testing import TestingShell
from sql.connection import ConnectionManager
from sql.magic import RenderMagic, SqlMagic
Expand Down

0 comments on commit 24952b3

Please sign in to comment.