Skip to content

Conversation

@magicmark
Copy link
Contributor

@magicmark magicmark commented Nov 29, 2025

As promised! Per #3863.

This PR adds a .pre-commit-hooks.yaml setup and our first hook, no-redundant-dataclasses.

Validation

(tested locally)

$ cat foo.py
from dataclasses import dataclass
import strawberry

@dataclass
@strawberry.type
class Foo:
    foo: str
$ poetry run pre-commit try-repo ../strawberry no-redundant-dataclasses --verbose --all-files
===============================================================================
Using config:
===============================================================================
repos:
-   repo: ../strawberry
    rev: 1c99829504d5d3b74195d9178734302c6b1b5883
    hooks:
    -   id: no-redundant-dataclasses
===============================================================================
[INFO] Initializing environment for ../strawberry.
[INFO] Installing environment for ../strawberry.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
No redundant dataclasses.................................................Failed
- hook id: no-redundant-dataclasses
- duration: 0.12s
- exit code: 1

Decorating strawberry types with dataclasses.dataclass is redundant.
Remove the dataclass decorator from the following classes:
- foo.py:6: Foo

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation. (wip)
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Summary by Sourcery

Add a Python-based linter hook to pre-commit that flags Strawberry GraphQL types redundantly decorated with dataclasses.dataclass.

New Features:

  • Expose a new console script entry point for a no-redundant-dataclasses checker.
  • Provide a pre-commit hook configuration for enforcing removal of raw dataclass decorators from Strawberry types.

Tests:

  • Add tests verifying the hook correctly fails on redundant dataclass decorations and passes on valid Strawberry types.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 29, 2025

Reviewer's Guide

Adds a new AST-based linter and pre-commit hook that fails when Strawberry GraphQL types are redundantly decorated with dataclasses.dataclass, wires it up as a CLI entry point, and tests the behavior.

File-Level Changes

Change Details Files
Introduce an AST-based checker and CLI entry point to detect Strawberry types redundantly decorated with dataclasses.dataclass.
  • Implement a Visitor subclass that inspects class decorators to detect classes that are both strawberry.type and a raw dataclass (either namespaced or imported).
  • Implement a main() function that parses filenames from CLI args, runs the visitor on each file, aggregates violations, prints a formatted error message, and returns a non-zero exit status when violations exist.
  • Expose the checker as a console_script entry point pre-commit-no-redundant-dataclasses in pyproject configuration.
strawberry/hooks/no_redundant_dataclasses.py
pyproject.toml
Configure the pre-commit hook that uses the new checker.
  • Add a .pre-commit-hooks.yaml configuration defining the no-redundant-dataclasses hook with name, description, entry, language, and python file type selection.
.pre-commit-hooks.yaml
Add tests to validate the hook behavior on passing and failing cases and tweak lint config for the new module.
  • Add tests that write temporary python files containing Strawberry types with both dataclasses.dataclass and strawberry.type decorators (namespaced and imported forms) and assert the checker exits with code 1.
  • Add a test that ensures a file with only strawberry.type decorator passes with exit code 0.
  • Update the lint ignore configuration to skip T201 in the new hooks package.
tests/hooks/test_no_redundant_dataclasses.py
pyproject.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@magicmark magicmark force-pushed the no-redundant-dataclasses_pre-commit-hook branch from ac8596f to 0430540 Compare November 29, 2025 05:43
@codecov
Copy link

codecov bot commented Nov 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.42%. Comparing base (c03892c) to head (72e307d).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4058      +/-   ##
==========================================
+ Coverage   94.41%   94.42%   +0.01%     
==========================================
  Files         536      539       +3     
  Lines       35036    35132      +96     
  Branches     1842     1848       +6     
==========================================
+ Hits        33079    33175      +96     
  Misses       1659     1659              
  Partials      298      298              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@magicmark magicmark force-pushed the no-redundant-dataclasses_pre-commit-hook branch from 0430540 to e6c1e18 Compare November 29, 2025 05:53
@magicmark magicmark changed the title Add no-redundant-dataclasses pre-commit hook Add no-redundant-dataclasses pre-commit hook Nov 29, 2025
@magicmark magicmark force-pushed the no-redundant-dataclasses_pre-commit-hook branch from e6c1e18 to 1ea803c Compare November 29, 2025 05:56
@magicmark magicmark force-pushed the no-redundant-dataclasses_pre-commit-hook branch from 1ea803c to 8fa7e63 Compare November 29, 2025 06:09
@magicmark magicmark marked this pull request as ready for review November 29, 2025 06:35
@botberry
Copy link
Member

botberry commented Nov 29, 2025

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


Add a pre-commit hook to prevent redundant @dataclass decorators on Strawberry types.

Since Strawberry types (@strawberry.type, @strawberry.input, @strawberry.interface) already provide dataclass functionality, decorating them with @dataclass is redundant. This hook detects and prevents this pattern, helping maintain cleaner code.

To use the hook, add it to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/strawberry-graphql/strawberry
    rev: <version>
    hooks:
      - id: no-redundant-dataclasses

Here's the tweet text:

🆕 Release (next) is out! Thanks to @mark_larah for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • In no_redundant_dataclasses.main you open files in binary mode and pass the raw bytes to ast.parse, which expects a string; switch to text mode with an explicit encoding (e.g. open(filename, encoding="utf-8")) or decode the bytes before parsing to avoid runtime errors on some Python versions.
  • Consider gracefully handling SyntaxError when parsing files with ast.parse so that the hook reports a clear message (or skips invalid files) instead of crashing the pre-commit run on syntactically invalid Python.
  • The visitor currently only matches @strawberry.type; if other Strawberry decorators (e.g. @strawberry.input, @strawberry.interface) should also forbid dataclasses.dataclass, it might be worth generalizing the decorator check to a configurable or broader set of Strawberry decorators.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `no_redundant_dataclasses.main` you open files in binary mode and pass the raw bytes to `ast.parse`, which expects a string; switch to text mode with an explicit encoding (e.g. `open(filename, encoding="utf-8")`) or decode the bytes before parsing to avoid runtime errors on some Python versions.
- Consider gracefully handling `SyntaxError` when parsing files with `ast.parse` so that the hook reports a clear message (or skips invalid files) instead of crashing the pre-commit run on syntactically invalid Python.
- The visitor currently only matches `@strawberry.type`; if other Strawberry decorators (e.g. `@strawberry.input`, `@strawberry.interface`) should also forbid `dataclasses.dataclass`, it might be worth generalizing the decorator check to a configurable or broader set of Strawberry decorators.

## Individual Comments

### Comment 1
<location> `strawberry/hooks/no_redundant_dataclasses.py:22-31` </location>
<code_context>
+        is_strawberry_class = False
+        is_raw_dataclass = False
+
+        for decorator in node.decorator_list:
+            if (
+                isinstance(decorator, ast.Attribute)
+                and isinstance(decorator.value, ast.Name)
+                and decorator.value.id == "strawberry"
+                and decorator.attr == "type"
+            ) or (
+                isinstance(decorator, ast.Call)
+                and isinstance(decorator.func, ast.Attribute)
+                and isinstance(decorator.func.value, ast.Name)
+                and decorator.func.value.id == "strawberry"
+                and decorator.func.attr == "type"
+            ):
+                is_strawberry_class = True
+
+            if (isinstance(decorator, ast.Name) and decorator.id == "dataclass") or (
+                isinstance(decorator, ast.Attribute)
+                and isinstance(decorator.value, ast.Name)
</code_context>

<issue_to_address>
**suggestion:** Current detection only covers `strawberry.type` and misses other Strawberry decorators that also imply dataclasses.

The detection logic only flags `@strawberry.type` / `@strawberry.type()` as Strawberry classes. Other decorators like `@strawberry.input`, `@strawberry.interface`, etc. are also dataclass-based and should likely be treated the same way. Consider generalizing `is_strawberry_class` to match any relevant `strawberry.<...>` decorator (possibly via a small allowlist) rather than hard-coding `attr == "type"`, so the hook also covers these cases.
</issue_to_address>

### Comment 2
<location> `strawberry/hooks/no_redundant_dataclasses.py:58-59` </location>
<code_context>
+    violations: list[str] = []
+
+    for filename in args.filenames:
+        with Path(filename).open("rb") as f:
+            tree = ast.parse(f.read(), filename=filename)
+            visitor = Visitor()
+            visitor.visit(tree)
</code_context>

<issue_to_address>
**issue (bug_risk):** Consider handling `SyntaxError` (and possibly `UnicodeDecodeError`) when parsing files so the hook degrades gracefully.

Right now, a syntax or decoding issue in any file will cause `ast.parse` to raise and abort the whole hook run. It would be better to catch `SyntaxError` (and possibly `UnicodeError`) around the parse, then either record a violation for that file or skip it with a clear diagnostic, so other files can still be processed.
</issue_to_address>

### Comment 3
<location> `tests/hooks/test_no_redundant_dataclasses.py:6-15` </location>
<code_context>
+from strawberry.hooks.no_redundant_dataclasses import main
+
+
+def test_check_namespaced_decorator(tmp_path):
+    code = """
+    import strawberry
+    import dataclasses
+
+    @dataclasses.dataclass
+    @strawberry.type
+    class Foo: ...
+    """
+    file = tmp_path / "foo.py"
+    file.write_text(dedent(code), encoding="utf-8")
+    exit_code = main([str(file)])
+    assert exit_code == 1
+
+
</code_context>

<issue_to_address>
**issue (testing):** Add tests for `@dataclasses.dataclass()` / `@dataclass()` call-style decorators

The current test only covers `dataclass` used as a bare decorator, but not when it’s called (e.g. `@dataclasses.dataclass()` or `@dataclass(eq=False)`). Since call-style usage is common, please add tests like:

```python
@dataclasses.dataclass()
@strawberry.type
class Foo: ...
```

and

```python
from dataclasses import dataclass

@dataclass(eq=False)
@strawberry.type
class Foo: ...
```

to ensure the behavior is clearly defined and to catch any discrepancies for call-style dataclass decorators.
</issue_to_address>

### Comment 4
<location> `tests/hooks/test_no_redundant_dataclasses.py:36-45` </location>
<code_context>
+    assert exit_code == 1
+
+
+def test_check_passing_file(tmp_path):
+    code = """
+    import strawberry
+
+    @strawberry.type
+    class Foo: ...
+    """
+    file = tmp_path / "foo.py"
+    file.write_text(dedent(code), encoding="utf-8")
+    exit_code = main([str(file)])
+    assert exit_code == 0
</code_context>

<issue_to_address>
**suggestion (testing):** Add negative tests to ensure non-strawberry dataclasses are not flagged

Right now we only cover the positive Strawberry case. Please also add tests with a plain dataclass (both `import dataclasses` and `from dataclasses import dataclass`) with no Strawberry decorator, and assert `exit_code == 0` in both. This will confirm the hook only flags *combined* dataclass + Strawberry types, not any dataclass usage.
</issue_to_address>

### Comment 5
<location> `strawberry/hooks/no_redundant_dataclasses.py:64` </location>
<code_context>
def main(argv: Sequence[str] | None = None) -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("filenames", nargs="*")
    args = parser.parse_args(argv)
    violations: list[str] = []

    for filename in args.filenames:
        with Path(filename).open("rb") as f:
            tree = ast.parse(f.read(), filename=filename)
            visitor = Visitor()
            visitor.visit(tree)
            violations.extend(f"- {filename}{error}" for error in visitor.errors)

    if len(violations) == 0:
        return 0

    msg = "\n".join(
        (
            "Decorating strawberry types with dataclasses.dataclass is redundant.",
            "Remove the dataclass decorator from the following classes:",
            *violations,
        )
    )

    print(msg)
    return 1

</code_context>

<issue_to_address>
**suggestion (code-quality):** Simplify sequence length comparison ([`simplify-len-comparison`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/simplify-len-comparison/))

```suggestion
    if not violations:
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +58 to +59
with Path(filename).open("rb") as f:
tree = ast.parse(f.read(), filename=filename)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Consider handling SyntaxError (and possibly UnicodeDecodeError) when parsing files so the hook degrades gracefully.

Right now, a syntax or decoding issue in any file will cause ast.parse to raise and abort the whole hook run. It would be better to catch SyntaxError (and possibly UnicodeError) around the parse, then either record a violation for that file or skip it with a clear diagnostic, so other files can still be processed.

Comment on lines +6 to +15
def test_check_namespaced_decorator(tmp_path):
code = """
import strawberry
import dataclasses

@dataclasses.dataclass
@strawberry.type
class Foo: ...
"""
file = tmp_path / "foo.py"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): Add tests for @dataclasses.dataclass() / @dataclass() call-style decorators

The current test only covers dataclass used as a bare decorator, but not when it’s called (e.g. @dataclasses.dataclass() or @dataclass(eq=False)). Since call-style usage is common, please add tests like:

@dataclasses.dataclass()
@strawberry.type
class Foo: ...

and

from dataclasses import dataclass

@dataclass(eq=False)
@strawberry.type
class Foo: ...

to ensure the behavior is clearly defined and to catch any discrepancies for call-style dataclass decorators.

Copy link
Collaborator

@Ckk3 Ckk3 Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this comment @magicmark and I see that you added a emoji too.

I created some tests to check it its is happen and looks like we dont show anything in this cases:

def test_check_dataclass_with_empty_parentheses(tmp_path):
    code = """
    import strawberry
    from dataclasses import dataclass

    @dataclass()
    @strawberry.type
    class Foo: ...
    """
    file = tmp_path / "foo.py"
    file.write_text(dedent(code), encoding="utf-8")
    exit_code = main([str(file)])
    assert exit_code == 1


def test_check_dataclass_with_parameters(tmp_path):
    code = """
    import strawberry
    from dataclasses import dataclass

    @dataclass(frozen=True)
    @strawberry.type
    class Foo: ...
    """
    file = tmp_path / "foo.py"
    file.write_text(dedent(code), encoding="utf-8")
    exit_code = main([str(file)])
    assert exit_code == 1


def test_check_namespaced_dataclass_with_parentheses(tmp_path):
    code = """
    import strawberry
    import dataclasses

    @dataclasses.dataclass()
    @strawberry.type
    class Foo: ...
    """
    file = tmp_path / "foo.py"
    file.write_text(dedent(code), encoding="utf-8")
    exit_code = main([str(file)])
    assert exit_code == 1


def test_check_namespaced_dataclass_with_parameters(tmp_path):
    code = """
    import strawberry
    import dataclasses

    @dataclasses.dataclass(frozen=True)
    @strawberry.type
    class Foo: ...
    """
    file = tmp_path / "foo.py"
    file.write_text(dedent(code), encoding="utf-8")
    exit_code = main([str(file)])
    assert exit_code == 1

What you think adding this tests and updating the code to handle that?
I will add another comment in test_redundant_dataclasses.py with the changes I've made to fix it 😉.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests look great to me and they cover exactly the call-style cases I was worried about: empty parentheses and parameterized decorators, both for the direct @dataclass import and the namespaced @dataclasses.dataclass form.

I’d definitely be in favor of adding them, along with the corresponding code changes you mentioned in test_redundant_dataclasses.py to make the hook actually flag these patterns. Once the implementation is updated so that all four new tests fail before the change and pass after it, we’ll have really solid coverage of the decorator variants people are likely to use.

When you push the changes, I’ll re-review with the updated implementation and tests, but conceptually: yes, please go ahead and add these tests and handle those cases in the hook logic.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 29, 2025

Greptile Overview

Greptile Summary

Adds a pre-commit hook to detect and prevent redundant @dataclass decorators on Strawberry GraphQL types, since Strawberry decorators automatically apply dataclass behavior internally.

  • Implements AST-based checker that scans Python files for classes decorated with both @dataclass and @strawberry.type
  • Hook correctly detects both namespaced (dataclasses.dataclass) and imported (dataclass) decorator patterns
  • Missing coverage for @strawberry.input and @strawberry.interface decorators, which also make @dataclass redundant

Confidence Score: 4/5

  • This PR is safe to merge with one logical gap to address
  • The implementation is solid and well-tested for @strawberry.type, but is missing detection for @strawberry.input and @strawberry.interface decorators which also make @dataclass redundant. This is a functional gap rather than a bug, and the hook will still work correctly for its current scope.
  • Pay attention to strawberry/hooks/no_redundant_dataclasses.py to extend coverage to all Strawberry decorators

Important Files Changed

File Analysis

Filename Score Overview
strawberry/hooks/no_redundant_dataclasses.py 4/5 AST-based checker that detects redundant @dataclass on @strawberry.type classes; missing coverage for @strawberry.input and @strawberry.interface
tests/hooks/test_no_redundant_dataclasses.py 4/5 Tests cover basic cases for @strawberry.type but missing coverage for @strawberry.input and @strawberry.interface

Sequence Diagram

sequenceDiagram
    participant PC as Pre-commit
    participant Hook as no_redundant_dataclasses
    participant AST as AST Parser
    participant Visitor as Visitor

    PC->>Hook: Execute with file paths
    loop For each file
        Hook->>AST: Parse Python file
        AST-->>Hook: Return AST tree
        Hook->>Visitor: Visit tree nodes
        Visitor->>Visitor: Check ClassDef nodes
        alt Has @strawberry.type AND @dataclass
            Visitor->>Visitor: Record error
        end
        Visitor-->>Hook: Return errors list
    end
    alt Violations found
        Hook->>PC: Exit code 1 + error message
    else No violations
        Hook->>PC: Exit code 0
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 29, 2025

CodSpeed Performance Report

Merging #4058 will not alter performance

Comparing magicmark:no-redundant-dataclasses_pre-commit-hook (72e307d) with main (23f8c50)

Summary

✅ 28 untouched

magicmark and others added 4 commits November 29, 2025 10:31
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@magicmark
Copy link
Contributor Author

magicmark commented Dec 5, 2025

@patrick91 ready for review! all checks passing now.

Comment on lines +6 to +15
def test_check_namespaced_decorator(tmp_path):
code = """
import strawberry
import dataclasses

@dataclasses.dataclass
@strawberry.type
class Foo: ...
"""
file = tmp_path / "foo.py"
Copy link
Collaborator

@Ckk3 Ckk3 Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this comment @magicmark and I see that you added a emoji too.

I created some tests to check it its is happen and looks like we dont show anything in this cases:

def test_check_dataclass_with_empty_parentheses(tmp_path):
    code = """
    import strawberry
    from dataclasses import dataclass

    @dataclass()
    @strawberry.type
    class Foo: ...
    """
    file = tmp_path / "foo.py"
    file.write_text(dedent(code), encoding="utf-8")
    exit_code = main([str(file)])
    assert exit_code == 1


def test_check_dataclass_with_parameters(tmp_path):
    code = """
    import strawberry
    from dataclasses import dataclass

    @dataclass(frozen=True)
    @strawberry.type
    class Foo: ...
    """
    file = tmp_path / "foo.py"
    file.write_text(dedent(code), encoding="utf-8")
    exit_code = main([str(file)])
    assert exit_code == 1


def test_check_namespaced_dataclass_with_parentheses(tmp_path):
    code = """
    import strawberry
    import dataclasses

    @dataclasses.dataclass()
    @strawberry.type
    class Foo: ...
    """
    file = tmp_path / "foo.py"
    file.write_text(dedent(code), encoding="utf-8")
    exit_code = main([str(file)])
    assert exit_code == 1


def test_check_namespaced_dataclass_with_parameters(tmp_path):
    code = """
    import strawberry
    import dataclasses

    @dataclasses.dataclass(frozen=True)
    @strawberry.type
    class Foo: ...
    """
    file = tmp_path / "foo.py"
    file.write_text(dedent(code), encoding="utf-8")
    exit_code = main([str(file)])
    assert exit_code == 1

What you think adding this tests and updating the code to handle that?
I will add another comment in test_redundant_dataclasses.py with the changes I've made to fix it 😉.

):
is_strawberry_class = True

if (isinstance(decorator, ast.Name) and decorator.id == "dataclass") or (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking)

@magicmark What you think about also detect when dataclass() is called with parentheses (empty or with args like dataclass(frozen=True))?

Please know that this was also mentioned in this sourcery comment where I added some tests to see if this is happening

Here is the code I've made that adds validations to this cases:

            # Check for dataclass decorator (with or without parentheses)
            decorator_node = (
                decorator.func if isinstance(decorator, ast.Call) else decorator
            )

            if (
                isinstance(decorator_node, ast.Name) and decorator_node.id == "dataclass"
            ) or (
                isinstance(decorator_node, ast.Attribute)
                and isinstance(decorator_node.value, ast.Name)
                and decorator_node.value.id == "dataclasses"
                and decorator_node.attr == "dataclass"
            ):
                is_raw_dataclass = True

@patrick91
Copy link
Member

shall we document this? 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants