Skip to content
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

add tests for an issue that i accidentally fixed #916

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,14 @@ def takes_arg(value: object) -> TypeIs[Callable[[int], None]]: ...

def _(value: Callable[[], None] | Callable[[int], None]):
if takes_arg(value):
assert_type(value, Callable[[int], None])
assert_type(value, Callable[[int], None])

# test for an upstream bug that i accidentally fixed
# https://github.com/DetachHead/basedpyright/issues/452
class Bar:
...
class Baz(Bar):
def __call__(self): ...
def _[T, **P](value: Callable[P, T]):
if isinstance(value, Bar):
reveal_type(value)
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,15 @@ def takes_arg(value: object) -> TypeIs[Callable[[int], None]]: ...

def _(value: Callable[[], None] | Callable[[int], None]):
if takes_arg(value):
assert_type(value, Callable[[int], None])
assert_type(value, Callable[[int], None])


# test for an upstream bug that i accidentally fixed
# https://github.com/DetachHead/basedpyright/issues/452
class Bar:
...
class Baz(Bar):
def __call__(self): ...
def _[T, **P](value: Callable[P, T]):
if isinstance(value, Bar):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ describe('narrowing type vars using their bounds', () => {
const analysisResults = typeAnalyzeSampleFiles(['typeNarrowingUsingBounds.py'], configOptions);
validateResultsButBased(analysisResults, {
errors: [],
infos: [{ line: 124, message: 'Type of "f" is "<subclass of Callable and staticmethod[..., object]>"' }],
infos: [
{ line: 124, message: 'Type of "f" is "<subclass of Callable and staticmethod[..., object]>"' },
{ line: 152, message: 'Type of "value" is "<subclass of Callable and Bar>"' },
],
});
});
test('disabled', () => {
Expand All @@ -135,7 +138,7 @@ describe('narrowing type vars using their bounds', () => {
configOptions.diagnosticRuleSet.strictGenericNarrowing = false;
const analysisResults = typeAnalyzeSampleFiles(['typeNarrowingUsingBoundsDisabled.py'], configOptions);
validateResultsButBased(analysisResults, {
errors: [],
hints: [{ line: 151, code: DiagnosticRule.reportUnreachable }],
});
});
});
Loading