Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 24, 2023
1 parent af3c5ba commit 86cde88
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
2 changes: 0 additions & 2 deletions docs/codegen/query-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ from strawberry.codegen.types import GraphQLType, GraphQLOperation


class QueryCodegenPlugin:

def __init__(self, query: Path) -> None:
"""Initialize the plugin.
Expand Down Expand Up @@ -155,7 +154,6 @@ The interface for the ConsolePlugin looks like:

```python
class ConsolePlugin:

def __init__(self, output_dir: Path):
"""Initialize the plugin and tell it where the output should be written."""
...
Expand Down
14 changes: 8 additions & 6 deletions strawberry/cli/commands/codegen.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from __future__ import annotations

import contextlib
import functools
import importlib
import inspect
import warnings
from pathlib import Path
from typing import List, Optional, Type
from typing import TYPE_CHECKING, List, Optional, Type

import rich
import typer
Expand All @@ -17,6 +14,9 @@
from strawberry.codegen.plugins.python import PythonPlugin
from strawberry.codegen.plugins.typescript import TypeScriptPlugin

if TYPE_CHECKING:
from pathlib import Path


def _is_codegen_plugin(obj: object) -> bool:
return (
Expand Down Expand Up @@ -64,7 +64,7 @@ def _import_plugin(plugin: str) -> Optional[Type[QueryCodegenPlugin]]:
return None


@functools.lru_cache()
@functools.lru_cache
def _load_plugin(plugin_path: str) -> Type[QueryCodegenPlugin]:
# try to import plugin_name from current folder
# then try to import from strawberry.codegen.plugins
Expand Down Expand Up @@ -146,7 +146,9 @@ def codegen(
elif isinstance(p, TypeScriptPlugin):
p.outfile_name = q.stem + ".ts"

Check warning on line 147 in strawberry/cli/commands/codegen.py

View check run for this annotation

Codecov / codecov/patch

strawberry/cli/commands/codegen.py#L147

Added line #L147 was not covered by tests

code_generator = QueryCodegen(schema_symbol, plugins=plugins, console_plugin=console_plugin)
code_generator = QueryCodegen(

Check warning on line 149 in strawberry/cli/commands/codegen.py

View check run for this annotation

Codecov / codecov/patch

strawberry/cli/commands/codegen.py#L149

Added line #L149 was not covered by tests
schema_symbol, plugins=plugins, console_plugin=console_plugin
)
code_generator.run(q.read_text())

Check warning on line 152 in strawberry/cli/commands/codegen.py

View check run for this annotation

Codecov / codecov/patch

strawberry/cli/commands/codegen.py#L152

Added line #L152 was not covered by tests

console_plugin.after_all_finished()

Check warning on line 154 in strawberry/cli/commands/codegen.py

View check run for this annotation

Codecov / codecov/patch

strawberry/cli/commands/codegen.py#L154

Added line #L154 was not covered by tests
2 changes: 1 addition & 1 deletion strawberry/codegen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .query_codegen import (
ConsolePlugin,
CodegenFile,
CodegenResult,
ConsolePlugin,
QueryCodegen,
QueryCodegenPlugin,
)
Expand Down
3 changes: 2 additions & 1 deletion strawberry/codegen/plugins/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import textwrap
from collections import defaultdict
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Dict, List, Optional, Set

from strawberry.codegen import CodegenFile, QueryCodegenPlugin
Expand All @@ -18,6 +17,8 @@
)

if TYPE_CHECKING:
from pathlib import Path

from strawberry.codegen.types import (
GraphQLArgumentValue,
GraphQLField,
Expand Down
3 changes: 2 additions & 1 deletion strawberry/codegen/plugins/typescript.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import textwrap
from pathlib import Path
from typing import TYPE_CHECKING, List

from strawberry.codegen import CodegenFile, QueryCodegenPlugin
Expand All @@ -15,6 +14,8 @@
)

if TYPE_CHECKING:
from pathlib import Path

from strawberry.codegen.types import GraphQLField, GraphQLOperation, GraphQLType


Expand Down
4 changes: 2 additions & 2 deletions strawberry/codegen/query_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import MISSING, dataclass
from enum import Enum
from functools import cmp_to_key, partial
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -17,9 +18,9 @@
Union,
cast,
)
import rich
from typing_extensions import Literal, Protocol

import rich
from graphql import (
BooleanValueNode,
EnumValueNode,
Expand Down Expand Up @@ -88,7 +89,6 @@
)

if TYPE_CHECKING:
from pathlib import Path

from graphql import (
ArgumentNode,
Expand Down
1 change: 0 additions & 1 deletion tests/codegen/test_query_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from pathlib import Path
from typing import Type
from unittest import mock

import pytest
from pytest_snapshot.plugin import Snapshot
Expand Down

0 comments on commit 86cde88

Please sign in to comment.