Skip to content

Commit

Permalink
Merge pull request #125 from simonsobs/dev
Browse files Browse the repository at this point in the history
Format code with `ruff`
  • Loading branch information
TaiSakuma authored Sep 25, 2024
2 parents 6f4eeed + 594d36a commit c3f5fbe
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 44 deletions.
37 changes: 27 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,33 @@ filterwarnings = ["ignore::hypothesis.errors.NonInteractiveExampleWarning"]
log_cli = false
log_cli_level = "INFO"

[tool.black]
skip-string-normalization = true
target_version = ['py310', 'py311', 'py312']
exclude = '''(?x)(
src/nextline_rdb/aalembic/versions/.*\.py$
| example_script/.*\.py$
)'''
[tool.ruff]
line-length = 88
extend-exclude = ["src/nextline_rdb/alembic/versions", "example_script"]

[tool.ruff.format]
quote-style = "preserve"

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
]
ignore = [
"E203", # Whitespace before '{symbol}'
"E265", # Block comment should start with #
"E266", # Too many leading # before block comment
"E501", # Line too long ({width} > {limit})
"E741", # Ambiguous variable name '{name}'
]

[tool.ruff.lint.mccabe]
max-complexity = 20

[tool.ruff.lint.isort]
# known-first-party = ["nextline"]

[tool.coverage.run]
branch = true
Expand All @@ -84,9 +104,6 @@ omit = ["src/nextline_rdb/__about__.py"]
[tool.coverage.report]
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]

[tool.isort]
profile = "black"

[tool.mypy]
plugins = "strawberry.ext.mypy_plugin"
exclude = '''(?x)(
Expand Down
4 changes: 0 additions & 4 deletions setup.cfg

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from hypothesis import strategies as st

from nextline_rdb.utils.strategies import st_python_scripts, st_none_or
from nextline_rdb.utils.strategies import st_none_or, st_python_scripts

from .. import Script

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def st_thread_task_no() -> st.SearchStrategy[tuple[int, int | None]]:


def sort_thread_task_nos(
thread_task_nos: Iterable[tuple[int, int | None]]
thread_task_nos: Iterable[tuple[int, int | None]],
) -> list[tuple[int, int | None]]:
return sorted(thread_task_nos, key=lambda x: (x[0], x[1] or 0))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def st_thread_task_no() -> st.SearchStrategy[tuple[int, int | None]]:


def sort_thread_task_nos(
thread_task_nos: Iterable[tuple[int, int | None]]
thread_task_nos: Iterable[tuple[int, int | None]],
) -> list[tuple[int, int | None]]:
return sorted(thread_task_nos, key=lambda x: (x[0], x[1] or 0))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from hypothesis import strategies as st

from nextline_rdb.utils.strategies import st_python_scripts, st_none_or
from nextline_rdb.utils.strategies import st_none_or, st_python_scripts

from .. import Script

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def st_thread_task_no() -> st.SearchStrategy[tuple[int, int | None]]:


def sort_thread_task_nos(
thread_task_nos: Iterable[tuple[int, int | None]]
thread_task_nos: Iterable[tuple[int, int | None]],
) -> list[tuple[int, int | None]]:
return sorted(thread_task_nos, key=lambda x: (x[0], x[1] or 0))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def st_thread_task_no() -> st.SearchStrategy[tuple[int, int | None]]:


def sort_thread_task_nos(
thread_task_nos: Iterable[tuple[int, int | None]]
thread_task_nos: Iterable[tuple[int, int | None]],
) -> list[tuple[int, int | None]]:
return sorted(thread_task_nos, key=lambda x: (x[0], x[1] or 0))

Expand Down
2 changes: 1 addition & 1 deletion src/nextline_rdb/models/strategies/st_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from hypothesis import strategies as st

from nextline_rdb.utils.strategies import st_python_scripts, st_none_or
from nextline_rdb.utils.strategies import st_none_or, st_python_scripts

from .. import Script

Expand Down
2 changes: 1 addition & 1 deletion src/nextline_rdb/models/strategies/st_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def st_thread_task_no() -> st.SearchStrategy[tuple[int, int | None]]:


def sort_thread_task_nos(
thread_task_nos: Iterable[tuple[int, int | None]]
thread_task_nos: Iterable[tuple[int, int | None]],
) -> list[tuple[int, int | None]]:
return sorted(thread_task_nos, key=lambda x: (x[0], x[1] or 0))

Expand Down
20 changes: 10 additions & 10 deletions src/nextline_rdb/schema/nodes/run_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ class RunNode:
script: Optional[str]
exception: Optional[str]

traces: Connection[
Annotated['TraceNode', strawberry.lazy('.trace_node')]
] = strawberry.field(resolver=_resolve_traces)
traces: Connection[Annotated['TraceNode', strawberry.lazy('.trace_node')]] = (
strawberry.field(resolver=_resolve_traces)
)

trace_calls: Connection[
Annotated['TraceCallNode', strawberry.lazy('.trace_call_node')]
] = strawberry.field(resolver=_resolve_trace_calls)

prompts: Connection[
Annotated['PromptNode', strawberry.lazy('.prompt_node')]
] = strawberry.field(resolver=_resolve_prompts)
prompts: Connection[Annotated['PromptNode', strawberry.lazy('.prompt_node')]] = (
strawberry.field(resolver=_resolve_prompts)
)

stdouts: Connection[
Annotated['StdoutNode', strawberry.lazy('.stdout_node')]
] = strawberry.field(resolver=_resolve_stdouts)
stdouts: Connection[Annotated['StdoutNode', strawberry.lazy('.stdout_node')]] = (
strawberry.field(resolver=_resolve_stdouts)
)

@classmethod
def from_model(cls: type['RunNode'], model: Run) -> 'RunNode':
Expand Down
6 changes: 3 additions & 3 deletions src/nextline_rdb/schema/nodes/trace_call_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def trace(self) -> Annotated['TraceNode', strawberry.lazy('.trace_node')]:

return TraceNode.from_model(self._model.trace)

prompts: Connection[
Annotated['PromptNode', strawberry.lazy('.prompt_node')]
] = strawberry.field(resolver=_resolve_prompts)
prompts: Connection[Annotated['PromptNode', strawberry.lazy('.prompt_node')]] = (
strawberry.field(resolver=_resolve_prompts)
)

@classmethod
def from_model(
Expand Down
12 changes: 6 additions & 6 deletions src/nextline_rdb/schema/nodes/trace_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def run(self) -> Annotated['RunNode', strawberry.lazy('.run_node')]:

return RunNode.from_model(self._model.run)

prompts: Connection[
Annotated['PromptNode', strawberry.lazy('.prompt_node')]
] = strawberry.field(resolver=_resolve_prompts)
prompts: Connection[Annotated['PromptNode', strawberry.lazy('.prompt_node')]] = (
strawberry.field(resolver=_resolve_prompts)
)

stdouts: Connection[
Annotated['StdoutNode', strawberry.lazy('.stdout_node')]
] = strawberry.field(resolver=_resolve_stdouts)
stdouts: Connection[Annotated['StdoutNode', strawberry.lazy('.stdout_node')]] = (
strawberry.field(resolver=_resolve_stdouts)
)

@classmethod
def from_model(cls: type['TraceNode'], model: db_models.Trace) -> 'TraceNode':
Expand Down
3 changes: 1 addition & 2 deletions src/nextline_rdb/utils/strategies/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
class StMinMaxValuesFactory(Protocol[T]):
def __call__(
self, *, min_value: Optional[T] = None, max_value: Optional[T] = None
) -> st.SearchStrategy[T]:
...
) -> st.SearchStrategy[T]: ...


def st_none_or(st_: st.SearchStrategy[T]) -> st.SearchStrategy[Optional[T]]:
Expand Down
2 changes: 1 addition & 1 deletion tests/schema/queries/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def test_run(data: st.DataObject) -> None:
QUERY_RDB_RUN, variable_values=variables, context_value={'db': db}
)
note(f'resp: {resp}')

assert isinstance(resp, ExecutionResult)
assert resp.data

Expand Down

0 comments on commit c3f5fbe

Please sign in to comment.