-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle named tuple in base class list
Summary: This diff eliminates some of the special casing of named tuple base classes and bans multiple inheritance for named tuples. This diff does not implement any other typechecking functionality for named tuples. Reviewed By: ndmitchell Differential Revision: D68250607 fbshipit-source-id: 418b45f773a2e1d45c56eda123abdaf8f68f06d2
- Loading branch information
1 parent
f8452b6
commit a146a38
Showing
8 changed files
with
73 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
use crate::testcase; | ||
|
||
testcase!( | ||
test_named_tuple, | ||
r#" | ||
from typing import NamedTuple | ||
class Pair(NamedTuple): | ||
x: int | ||
y: int | ||
"#, | ||
); | ||
|
||
testcase!( | ||
test_named_tuple_multiple_inheritance, | ||
r#" | ||
from typing import NamedTuple | ||
class Foo: pass | ||
class Pair(NamedTuple, Foo): # E: Named tuples do not support multiple inheritance | ||
x: int | ||
y: int | ||
class Pair2(NamedTuple): | ||
x: int | ||
y: int | ||
class Pair3(Pair2, Foo): # E: Named tuples do not support multiple inheritance | ||
pass | ||
"#, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters