Skip to content

Commit

Permalink
Fix typing for class_registry.get_class (#2735)
Browse files Browse the repository at this point in the history
* Fix typing for class_registry.get_class

* Update changelog
  • Loading branch information
sloria authored Jan 7, 2025
1 parent 9136ff9 commit 0902941
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
---------

3.24.1 (unreleased)
*******************

Bug fixes:

- Typing: Fix typing for `class_registry.get_class <marshmallow.class_registry.get_class>` (:pr:`2735`).

3.24.0 (2025-01-06)
*******************

Expand Down
4 changes: 2 additions & 2 deletions src/marshmallow/class_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class MyClass:


@typing.overload
def get_class(classname: str, all: typing.Literal[False]) -> SchemaType: ...
def get_class(classname: str, all: typing.Literal[False] = ...) -> SchemaType: ...


@typing.overload
def get_class(
classname: str, all: typing.Literal[True]
classname: str, all: typing.Literal[True] = ...
) -> list[SchemaType] | SchemaType: ...


Expand Down
4 changes: 4 additions & 0 deletions tests/mypy_test_cases/test_class_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from marshmallow import class_registry

# Works without passing `all`
class_registry.get_class("MySchema")

0 comments on commit 0902941

Please sign in to comment.