-
Notifications
You must be signed in to change notification settings - Fork 102
based overload consistency checks #1527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1469,6 +1469,8 @@ export class ConfigOptions { | |
| // Overrides the default timeout for file enumeration operations. | ||
| fileEnumerationTimeoutInSec?: number; | ||
|
|
||
| strictOverloadConsistency = true; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to document this new rule (both in
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, actually i think it probably should be a new diagnostic rule. this makes it much easier for users updating it to instantly know what the new setting to disable is if they don't agree with it |
||
|
|
||
| // https://github.com/microsoft/TypeScript/issues/3841 | ||
| declare ['constructor']: typeof ConfigOptions; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,8 +14,8 @@ def atomic(*, savepoint: bool = True) -> Callable[[F], F]: ... | |
|
|
||
|
|
||
| def atomic( | ||
| __func: Optional[Callable[..., None]] = None, *, savepoint: bool = True | ||
| ) -> Union[Callable[[], None], Callable[[F], F]]: ... | ||
| __func: F | None = None, *, savepoint: bool = True | ||
| ) -> Union[F, Callable[[F], F]]: ... | ||
|
Comment on lines
-17
to
+18
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this now an error? i couldn't reproduce it |
||
|
|
||
|
|
||
| @atomic | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,7 +74,7 @@ def deco2( | |
|
|
||
| def deco2( | ||
| x: Callable[[], T | None] = lambda: None, | ||
| ) -> Callable[[Callable[P, T]], Callable[P, T | None]]: ... | ||
| ) -> Callable[[Callable[P, T]], Callable[P, T]] | Callable[[Callable[P, T]], Callable[P, T | None]]: ... | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
|
|
||
|
|
||
| @deco2(x=dict) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ def overloaded1(x: A) -> str: ... | |
| def overloaded1(x: _T1) -> _T1: ... | ||
|
|
||
|
|
||
| def overloaded1(x: A | B) -> str | B: ... | ||
| def overloaded1[T: B](x: A | T) -> str | T: ... | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
|
|
||
|
|
||
| def func1(a: A | B, b: A | B | C): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ def func1(__iter1: Iterable[_T1], __iter2: Iterable[_T2]) -> Tuple[_T1, _T2]: .. | |
| def func1(*iterables: Iterable[_T1]) -> float: ... | ||
|
|
||
|
|
||
| def func1(*iterables: Iterable[_T1 | _T2]) -> Tuple[_T1 | _T2, ...] | float: ... | ||
| def func1(*iterables: Iterable[_T1 | _T2]) -> Tuple[_T1 | _T2, ...] | float: ... # pyright: ignore the too wide error | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we ignoring the error here instead of fixing it? also should add the error code to the ignore comment |
||
|
|
||
|
|
||
| def test1(x: Iterable[int]): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -326,7 +326,7 @@ def func20(choices: AnyStr) -> AnyStr: ... | |
| def func20(choices: AllStr) -> AllStr: ... | ||
|
|
||
|
|
||
| def func20(choices: AllStr) -> AllStr: ... | ||
| def func20(choices: AnyStr | AllStr) -> AnyStr | AllStr: ... | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems sus, the error message was "Overloaded implementation is not consistent with signature of overload 1" but that's not the error message you added. did we accidentally effect logic for other cases? |
||
|
|
||
|
|
||
| # This should generate an overlapping overload error. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,7 @@ test('OverloadOverride1', () => { | |
|
|
||
| test('OverloadImpl1', () => { | ||
| const analysisResults = TestUtils.typeAnalyzeSampleFiles(['overloadImpl1.py']); | ||
| TestUtils.validateResults(analysisResults, 6); | ||
| TestUtils.validateResults(analysisResults, 7); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a comment in |
||
| }); | ||
|
|
||
| test('OverloadImpl2', () => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.