|
5 | 5 | import sys |
6 | 6 | from abc import abstractmethod |
7 | 7 | from collections.abc import Iterable, Sequence |
8 | | -from typing import ( |
9 | | - TYPE_CHECKING, |
10 | | - Any, |
11 | | - ClassVar, |
12 | | - Final, |
13 | | - NamedTuple, |
14 | | - NewType, |
15 | | - TypeVar, |
16 | | - Union, |
17 | | - cast, |
18 | | - overload, |
19 | | -) |
| 8 | +from typing import TYPE_CHECKING, Any, ClassVar, Final, NewType, TypeVar, Union, cast, overload |
20 | 9 | from typing_extensions import Self, TypeAlias as _TypeAlias, TypeGuard |
21 | 10 |
|
22 | 11 | import mypy.nodes |
@@ -1247,10 +1236,10 @@ def accept(self, visitor: TypeVisitor[T]) -> T: |
1247 | 1236 | return visitor.visit_uninhabited_type(self) |
1248 | 1237 |
|
1249 | 1238 | def __hash__(self) -> int: |
1250 | | - return hash(UninhabitedType) |
| 1239 | + return hash((UninhabitedType, self.ambiguous)) |
1251 | 1240 |
|
1252 | 1241 | def __eq__(self, other: object) -> bool: |
1253 | | - return isinstance(other, UninhabitedType) |
| 1242 | + return isinstance(other, UninhabitedType) and other.ambiguous == self.ambiguous |
1254 | 1243 |
|
1255 | 1244 | def serialize(self) -> JsonDict: |
1256 | 1245 | return {".class": "UninhabitedType"} |
@@ -1607,11 +1596,25 @@ def bound(self) -> bool: |
1607 | 1596 | return bool(self.items) and self.items[0].is_bound |
1608 | 1597 |
|
1609 | 1598 |
|
1610 | | -class FormalArgument(NamedTuple): |
1611 | | - name: str | None |
1612 | | - pos: int | None |
1613 | | - typ: Type |
1614 | | - required: bool |
| 1599 | +class FormalArgument: |
| 1600 | + def __init__(self, name: str | None, pos: int | None, typ: Type, required: bool) -> None: |
| 1601 | + self.name = name |
| 1602 | + self.pos = pos |
| 1603 | + self.typ = typ |
| 1604 | + self.required = required |
| 1605 | + |
| 1606 | + def __eq__(self, other: object) -> bool: |
| 1607 | + if not isinstance(other, FormalArgument): |
| 1608 | + return NotImplemented |
| 1609 | + return ( |
| 1610 | + self.name == other.name |
| 1611 | + and self.pos == other.pos |
| 1612 | + and self.typ == other.typ |
| 1613 | + and self.required == other.required |
| 1614 | + ) |
| 1615 | + |
| 1616 | + def __hash__(self) -> int: |
| 1617 | + return hash((self.name, self.pos, self.typ, self.required)) |
1615 | 1618 |
|
1616 | 1619 |
|
1617 | 1620 | class Parameters(ProperType): |
|
0 commit comments