diff --git a/pyproject.toml b/pyproject.toml index 8bab6fb..b2a1f81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 @@ -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)( diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 6b4300a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -ignore = E203, E265, E266, E501, E741, W503 -max-line-length = 150 -max-complexity = 20 diff --git a/src/nextline_rdb/alembic/models/rev_4dc6a93dfed8/strategies/st_script.py b/src/nextline_rdb/alembic/models/rev_4dc6a93dfed8/strategies/st_script.py index 5c516fe..75d7ef5 100644 --- a/src/nextline_rdb/alembic/models/rev_4dc6a93dfed8/strategies/st_script.py +++ b/src/nextline_rdb/alembic/models/rev_4dc6a93dfed8/strategies/st_script.py @@ -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 diff --git a/src/nextline_rdb/alembic/models/rev_4dc6a93dfed8/strategies/st_trace.py b/src/nextline_rdb/alembic/models/rev_4dc6a93dfed8/strategies/st_trace.py index 0b7d235..00f7646 100644 --- a/src/nextline_rdb/alembic/models/rev_4dc6a93dfed8/strategies/st_trace.py +++ b/src/nextline_rdb/alembic/models/rev_4dc6a93dfed8/strategies/st_trace.py @@ -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)) diff --git a/src/nextline_rdb/alembic/models/rev_5a08750d6760/strategies/st_trace.py b/src/nextline_rdb/alembic/models/rev_5a08750d6760/strategies/st_trace.py index 0b7d235..00f7646 100644 --- a/src/nextline_rdb/alembic/models/rev_5a08750d6760/strategies/st_trace.py +++ b/src/nextline_rdb/alembic/models/rev_5a08750d6760/strategies/st_trace.py @@ -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)) diff --git a/src/nextline_rdb/alembic/models/rev_f3edea6dbde2/strategies/st_script.py b/src/nextline_rdb/alembic/models/rev_f3edea6dbde2/strategies/st_script.py index 5c516fe..75d7ef5 100644 --- a/src/nextline_rdb/alembic/models/rev_f3edea6dbde2/strategies/st_script.py +++ b/src/nextline_rdb/alembic/models/rev_f3edea6dbde2/strategies/st_script.py @@ -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 diff --git a/src/nextline_rdb/alembic/models/rev_f3edea6dbde2/strategies/st_trace.py b/src/nextline_rdb/alembic/models/rev_f3edea6dbde2/strategies/st_trace.py index d404d22..268f062 100644 --- a/src/nextline_rdb/alembic/models/rev_f3edea6dbde2/strategies/st_trace.py +++ b/src/nextline_rdb/alembic/models/rev_f3edea6dbde2/strategies/st_trace.py @@ -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)) diff --git a/src/nextline_rdb/alembic/models/rev_f9a742bb2297/strategies/st_trace.py b/src/nextline_rdb/alembic/models/rev_f9a742bb2297/strategies/st_trace.py index 0b7d235..00f7646 100644 --- a/src/nextline_rdb/alembic/models/rev_f9a742bb2297/strategies/st_trace.py +++ b/src/nextline_rdb/alembic/models/rev_f9a742bb2297/strategies/st_trace.py @@ -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)) diff --git a/src/nextline_rdb/models/strategies/st_script.py b/src/nextline_rdb/models/strategies/st_script.py index 5c516fe..75d7ef5 100644 --- a/src/nextline_rdb/models/strategies/st_script.py +++ b/src/nextline_rdb/models/strategies/st_script.py @@ -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 diff --git a/src/nextline_rdb/models/strategies/st_trace.py b/src/nextline_rdb/models/strategies/st_trace.py index 8d2e485..4efb891 100644 --- a/src/nextline_rdb/models/strategies/st_trace.py +++ b/src/nextline_rdb/models/strategies/st_trace.py @@ -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)) diff --git a/src/nextline_rdb/schema/nodes/run_node.py b/src/nextline_rdb/schema/nodes/run_node.py index 6123e0e..7fc6547 100644 --- a/src/nextline_rdb/schema/nodes/run_node.py +++ b/src/nextline_rdb/schema/nodes/run_node.py @@ -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': diff --git a/src/nextline_rdb/schema/nodes/trace_call_node.py b/src/nextline_rdb/schema/nodes/trace_call_node.py index 6ba1013..7a9d1e8 100644 --- a/src/nextline_rdb/schema/nodes/trace_call_node.py +++ b/src/nextline_rdb/schema/nodes/trace_call_node.py @@ -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( diff --git a/src/nextline_rdb/schema/nodes/trace_node.py b/src/nextline_rdb/schema/nodes/trace_node.py index 734d59f..df4b561 100644 --- a/src/nextline_rdb/schema/nodes/trace_node.py +++ b/src/nextline_rdb/schema/nodes/trace_node.py @@ -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': diff --git a/src/nextline_rdb/utils/strategies/misc.py b/src/nextline_rdb/utils/strategies/misc.py index db601bc..62aa489 100644 --- a/src/nextline_rdb/utils/strategies/misc.py +++ b/src/nextline_rdb/utils/strategies/misc.py @@ -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]]: diff --git a/tests/schema/queries/test_run.py b/tests/schema/queries/test_run.py index c82b5e0..e6645d9 100644 --- a/tests/schema/queries/test_run.py +++ b/tests/schema/queries/test_run.py @@ -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