Skip to content

Commit 04c4aa8

Browse files
committed
hack types.NoneType to work as a value of type[None]
We will want to revert this when `NoneType` is used as the class of `None`
1 parent e6f5e9e commit 04c4aa8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Basedmypy Changelog
22

33
## [Unreleased]
4+
5+
## [1.4.0]
46
### Added
57
- `ignore_any_from_errors` option to suppress `no-any-expr` messages from other errors
68
- Function types are inferred from Overloads, overrides and default values. (no overrides for now sorry)
@@ -10,6 +12,8 @@
1012
- Added a dependency on `basedtyping`
1113
### Enhancements
1214
- Render types a lot better in output messages
15+
### Fixes
16+
- `types.NoneType` now works as a value of `type[None]`
1317

1418
## [1.3.0]
1519
### Added

mypy/typeshed/stdlib/types.pyi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ from importlib.machinery import ModuleSpec
1818

1919
# pytype crashes if types.MappingProxyType inherits from collections.abc.Mapping instead of typing.Mapping
2020
from typing import Any, ClassVar, Generic, Mapping, TypeVar, overload # noqa: Y027
21-
from typing_extensions import Literal, ParamSpec, final
21+
from typing_extensions import Literal, ParamSpec, final, Final
2222

2323
__all__ = [
2424
"FunctionType",
@@ -634,9 +634,8 @@ if sys.version_info >= (3, 9):
634634
def __getattr__(self, name: str) -> Any: ... # incomplete
635635

636636
if sys.version_info >= (3, 10):
637-
@final
638-
class NoneType:
639-
def __bool__(self) -> Literal[False]: ...
637+
# This annotation allows `NoneType` to be used as a value of `type[None]`
638+
NoneType: Final[type[None]] = ...
640639
EllipsisType = ellipsis # noqa: F821 from builtins
641640
from builtins import _NotImplementedType
642641

0 commit comments

Comments
 (0)