Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/validkit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .v import v
from .validator import validate, ValidationError, Schema

__version__ = "1.1.0"
__version__ = "1.1.1"
__all__ = ["v", "validate", "ValidationError", "Schema"]
43 changes: 22 additions & 21 deletions src/validkit/validator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Generic, List, Optional, TypeVar, overload
from typing import Any, Dict, Generic, List, Optional, TypeVar, overload, TYPE_CHECKING
from .v import Validator, v

T = TypeVar("T")
Expand Down Expand Up @@ -156,26 +156,27 @@
# 4. Literal / Pre-validated?
return value

@overload
def validate(
data: Any,
schema: Schema[T],
partial: bool = ...,
base: Any = ...,
migrate: Optional[Dict[str, Any]] = ...,
collect_errors: bool = ...,
) -> T: ...


@overload
def validate(
data: Any,
schema: Any,
partial: bool = ...,
base: Any = ...,
migrate: Optional[Dict[str, Any]] = ...,
collect_errors: bool = ...,
) -> Any: ...
if TYPE_CHECKING:
# Overload definitions are used by type checkers only and skipped at runtime
@overload
def validate(
data: Any,
schema: Schema[T],
partial: bool = ...,
base: Any = ...,
migrate: Optional[Dict[str, Any]] = ...,
collect_errors: bool = ...,
) -> T: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.

Copilot Autofix

AI about 14 hours ago

General approach: remove the standalone ellipsis expression so that there are no top‑level statements without effects. We must not change the overload signatures or runtime behavior.

Best concrete fix: delete line 169 containing only ) -> T: ...? No — that’s valid, needed syntax. The reported line 169 is the sole ... line that is not attached to a def header. In the snippet, it is the terminator of the first overload, written on its own line as ) -> T: .... To avoid changing the meaning, we can move the ellipsis into a proper function body (which is standard for stub‑style overloads) and eliminate it as a separate statement. The minimal change is to rewrite the overload so that the ... is the function body directly under the signature, and remove the stray standalone ... line if it exists separately; in our snippet, that means turning the one‑line overload header with ... at the end into a multi‑line definition whose body is just ....

Concretely, in src/validkit/validator.py, inside the if TYPE_CHECKING: block, adjust the first overload definition so that the ellipsis is the function body, not a separate expression statement. No new imports or helpers are needed.

Suggested changeset 1
src/validkit/validator.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/validkit/validator.py b/src/validkit/validator.py
--- a/src/validkit/validator.py
+++ b/src/validkit/validator.py
@@ -166,7 +166,8 @@
         base: Any = ...,
         migrate: Optional[Dict[str, Any]] = ...,
         collect_errors: bool = ...,
-    ) -> T: ...
+    ) -> T:
+        ...
 
     @overload
     def validate(
EOF
@@ -166,7 +166,8 @@
base: Any = ...,
migrate: Optional[Dict[str, Any]] = ...,
collect_errors: bool = ...,
) -> T: ...
) -> T:
...

@overload
def validate(
Copilot is powered by AI and may make mistakes. Always verify output.

@overload
def validate(
data: Any,
schema: Any,
partial: bool = ...,
base: Any = ...,
migrate: Optional[Dict[str, Any]] = ...,
collect_errors: bool = ...,
) -> Any: ...

Check notice

Code scanning / CodeQL

Statement has no effect Note

This statement has no effect.

Copilot Autofix

AI about 14 hours ago

Generally, to fix a “statement has no effect” issue where ... is used as a body, replace the ellipsis expression with a proper no-op statement (pass) or a more meaningful implementation. In the context of @overload definitions inside if TYPE_CHECKING:, the best fix that does not alter runtime behavior is to turn ... into a minimal function body, i.e., pass. This keeps the overloads valid for type checkers while avoiding a useless standalone expression.

Concretely, in src/validkit/validator.py within the if TYPE_CHECKING: section, change the overloaded validate signatures so that each function has a body consisting of pass instead of ending the signature line with : .... For example, transform:

169:     ) -> T: ...

into a two-line definition:

169:     ) -> T:
170:         pass

and similarly for the second overload at lines 172–179. No new imports or helpers are required; pass is a built-in statement and will not affect behavior because if TYPE_CHECKING: ensures these blocks are not executed at runtime.

Suggested changeset 1
src/validkit/validator.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/validkit/validator.py b/src/validkit/validator.py
--- a/src/validkit/validator.py
+++ b/src/validkit/validator.py
@@ -166,7 +166,8 @@
         base: Any = ...,
         migrate: Optional[Dict[str, Any]] = ...,
         collect_errors: bool = ...,
-    ) -> T: ...
+    ) -> T:
+        pass
 
     @overload
     def validate(
@@ -176,7 +177,8 @@
         base: Any = ...,
         migrate: Optional[Dict[str, Any]] = ...,
         collect_errors: bool = ...,
-    ) -> Any: ...
+    ) -> Any:
+        pass
 
 
 def validate(
EOF
@@ -166,7 +166,8 @@
base: Any = ...,
migrate: Optional[Dict[str, Any]] = ...,
collect_errors: bool = ...,
) -> T: ...
) -> T:
pass

@overload
def validate(
@@ -176,7 +177,8 @@
base: Any = ...,
migrate: Optional[Dict[str, Any]] = ...,
collect_errors: bool = ...,
) -> Any: ...
) -> Any:
pass


def validate(
Copilot is powered by AI and may make mistakes. Always verify output.


def validate(
Expand Down
5 changes: 3 additions & 2 deletions tests/test_validkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,6 @@ def test_schema_generic_optional_field():

def test_schema_exported():
"""Schema is exported from the top-level package."""
import validkit
assert hasattr(validkit, "Schema")
import importlib
pkg = importlib.import_module("validkit")
assert hasattr(pkg, "Schema")
Loading