From 23050b3653aee35b23da634e609dbd5e1c6a0901 Mon Sep 17 00:00:00 2001 From: Zanie Date: Fri, 27 Oct 2023 12:15:59 -0500 Subject: [PATCH] Guard against dataclass types in jsonable implementation --- python/ruff-ecosystem/pyproject.toml | 4 ++-- python/ruff-ecosystem/ruff_ecosystem/check.py | 4 ++-- python/ruff-ecosystem/ruff_ecosystem/types.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/ruff-ecosystem/pyproject.toml b/python/ruff-ecosystem/pyproject.toml index 3009f975a8..23d7a51c3c 100644 --- a/python/ruff-ecosystem/pyproject.toml +++ b/python/ruff-ecosystem/pyproject.toml @@ -10,6 +10,6 @@ dependencies = ["unidiff==0.7.5"] [project.scripts] ruff-ecosystem = "ruff_ecosystem.cli:entrypoint" - [tool.ruff] -extend-select = ["I"] \ No newline at end of file +extend-select = ["I"] +preview = true \ No newline at end of file diff --git a/python/ruff-ecosystem/ruff_ecosystem/check.py b/python/ruff-ecosystem/ruff_ecosystem/check.py index ec5d782659..b266a3e028 100644 --- a/python/ruff-ecosystem/ruff_ecosystem/check.py +++ b/python/ruff-ecosystem/ruff_ecosystem/check.py @@ -4,11 +4,11 @@ Execution, comparison, and summary of `ruff check` ecosystem checks. from __future__ import annotations import asyncio +import dataclasses import re import time from asyncio import create_subprocess_exec from collections import Counter -import dataclasses from dataclasses import dataclass, field from pathlib import Path from subprocess import PIPE @@ -17,8 +17,8 @@ from typing import TYPE_CHECKING, Iterable, Iterator, Self, Sequence from ruff_ecosystem import logger from ruff_ecosystem.markdown import ( markdown_details, - markdown_project_section, markdown_plus_minus, + markdown_project_section, ) from ruff_ecosystem.types import ( Comparison, diff --git a/python/ruff-ecosystem/ruff_ecosystem/types.py b/python/ruff-ecosystem/ruff_ecosystem/types.py index b6b5cb19f6..e2a36d8f86 100644 --- a/python/ruff-ecosystem/ruff_ecosystem/types.py +++ b/python/ruff-ecosystem/ruff_ecosystem/types.py @@ -17,7 +17,7 @@ class Serializable(abc.ABC): def jsonable(self) -> Any: # Default implementation for dataclasses - if is_dataclass(self): + if is_dataclass(self) and not isinstance(self, type): return dataclasses.asdict(self) raise NotImplementedError()