Skip to content

Commit 2fd794c

Browse files
committed
Remove unused code to fix coverage
- Remove unused is_pydantic_v2_11() function and _is_v2_11 variable - Simplify chain_as_tuple by removing unused n==0 and n==1 optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 1855a5c commit 2fd794c

2 files changed

Lines changed: 2 additions & 16 deletions

File tree

src/datamodel_code_generator/types.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,9 @@ def validate(cls, v: Any) -> UnionIntFloat:
180180
def chain_as_tuple(*iterables: Iterable[T]) -> tuple[T, ...]:
181181
"""Chain multiple iterables and return as a tuple.
182182
183-
Optimized for common cases with 0-2 iterables to avoid chain() overhead.
183+
Optimized for the common case of 2 iterables to avoid chain() overhead.
184184
"""
185-
n = len(iterables)
186-
if n == 0: # pragma: no cover
187-
return ()
188-
if n == 1: # pragma: no cover
189-
return tuple(iterables[0])
190-
if n == 2: # noqa: PLR2004
185+
if len(iterables) == 2: # noqa: PLR2004
191186
return (*iterables[0], *iterables[1])
192187
return tuple(chain(*iterables))
193188

src/datamodel_code_generator/util.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def get_pydantic_version() -> tuple[Any, bool, bool]:
4747

4848

4949
_is_v2: bool | None = None
50-
_is_v2_11: bool | None = None
5150

5251

5352
def is_pydantic_v2() -> bool:
@@ -58,14 +57,6 @@ def is_pydantic_v2() -> bool:
5857
return _is_v2
5958

6059

61-
def is_pydantic_v2_11() -> bool:
62-
"""Check if pydantic v2.11+ is installed."""
63-
global _is_v2_11 # noqa: PLW0603
64-
if _is_v2_11 is None: # pragma: no branch
65-
_is_v2_11 = get_pydantic_version()[2]
66-
return _is_v2_11
67-
68-
6960
_YAML_1_2_BOOL_PATTERN = re.compile(r"^(?:true|false|True|False|TRUE|FALSE)$")
7061
_YAML_DEPRECATED_BOOL_VALUES = {"True", "False", "TRUE", "FALSE"}
7162

0 commit comments

Comments
 (0)