Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 1 addition & 4 deletions crates/ty_python_semantic/resources/mdtest/final.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class ChildOfBad(Bad):
def bar(self, x: str) -> str: ...
@overload
def bar(self, x: int) -> int: ... # error: [override-of-final-method]

@overload
def baz(self, x: str) -> str: ...
@overload
Expand Down Expand Up @@ -466,9 +466,6 @@ class B(A):
# Possible overrides of possibly `@final` methods...
class C(A):
if coinflip():
# TODO: the autofix here introduces invalid syntax because there are now no
# statements inside the `if:` branch
# (but it might still be a useful autofix in an IDE context?)
def method1(self) -> None: ... # error: [override-of-final-method]
else:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,18 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/final.md
40 | # Possible overrides of possibly `@final` methods...
41 | class C(A):
42 | if coinflip():
43 | # TODO: the autofix here introduces invalid syntax because there are now no
44 | # statements inside the `if:` branch
45 | # (but it might still be a useful autofix in an IDE context?)
46 | def method1(self) -> None: ... # error: [override-of-final-method]
47 | else:
48 | pass
49 |
50 | if coinflip():
51 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method]
52 | else:
53 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method]
54 |
55 | if coinflip():
56 | def method3(self) -> None: ... # error: [override-of-final-method]
57 | def method4(self) -> None: ... # error: [override-of-final-method]
43 | def method1(self) -> None: ... # error: [override-of-final-method]
44 | else:
45 | pass
46 |
47 | if coinflip():
48 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method]
49 | else:
50 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method]
51 |
52 | if coinflip():
53 | def method3(self) -> None: ... # error: [override-of-final-method]
54 | def method4(self) -> None: ... # error: [override-of-final-method]
```

# Diagnostics
Expand Down Expand Up @@ -220,14 +217,14 @@ note: This is an unsafe fix and may change runtime behavior

```
error[override-of-final-method]: Cannot override `A.method1`
--> src/mdtest_snippet.py:46:13
--> src/mdtest_snippet.py:43:13
|
44 | # statements inside the `if:` branch
45 | # (but it might still be a useful autofix in an IDE context?)
46 | def method1(self) -> None: ... # error: [override-of-final-method]
41 | class C(A):
42 | if coinflip():
43 | def method1(self) -> None: ... # error: [override-of-final-method]
| ^^^^^^^ Overrides a definition from superclass `A`
47 | else:
48 | pass
44 | else:
45 | pass
|
info: `A.method1` is decorated with `@final`, forbidding overrides
--> src/mdtest_snippet.py:8:9
Expand All @@ -243,26 +240,26 @@ info: `A.method1` is decorated with `@final`, forbidding overrides
|
help: Remove the override of `method1`
info: rule `override-of-final-method` is enabled by default
43 | # TODO: the autofix here introduces invalid syntax because there are now no
44 | # statements inside the `if:` branch
45 | # (but it might still be a useful autofix in an IDE context?)
40 | # Possible overrides of possibly `@final` methods...
41 | class C(A):
42 | if coinflip():
- def method1(self) -> None: ... # error: [override-of-final-method]
46 + # error: [override-of-final-method]
47 | else:
48 | pass
49 |
note: This is an unsafe fix and may change runtime behavior
43 + # error: [override-of-final-method]
44 | else:
45 | pass
46 |
note: This is a display-only fix and is likely to be incorrect

```

```
error[override-of-final-method]: Cannot override `A.method3`
--> src/mdtest_snippet.py:56:13
--> src/mdtest_snippet.py:53:13
|
55 | if coinflip():
56 | def method3(self) -> None: ... # error: [override-of-final-method]
52 | if coinflip():
53 | def method3(self) -> None: ... # error: [override-of-final-method]
| ^^^^^^^ Overrides a definition from superclass `A`
57 | def method4(self) -> None: ... # error: [override-of-final-method]
54 | def method4(self) -> None: ... # error: [override-of-final-method]
|
info: `A.method3` is decorated with `@final`, forbidding overrides
--> src/mdtest_snippet.py:20:9
Expand All @@ -277,23 +274,23 @@ info: `A.method3` is decorated with `@final`, forbidding overrides
|
help: Remove the override of `method3`
info: rule `override-of-final-method` is enabled by default
53 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method]
54 |
55 | if coinflip():
50 | def method2(self) -> None: ... # TODO: should emit [override-of-final-method]
51 |
52 | if coinflip():
- def method3(self) -> None: ... # error: [override-of-final-method]
56 + # error: [override-of-final-method]
57 | def method4(self) -> None: ... # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior
53 + # error: [override-of-final-method]
54 | def method4(self) -> None: ... # error: [override-of-final-method]
note: This is a display-only fix and is likely to be incorrect

```

```
error[override-of-final-method]: Cannot override `A.method4`
--> src/mdtest_snippet.py:57:13
--> src/mdtest_snippet.py:54:13
|
55 | if coinflip():
56 | def method3(self) -> None: ... # error: [override-of-final-method]
57 | def method4(self) -> None: ... # error: [override-of-final-method]
52 | if coinflip():
53 | def method3(self) -> None: ... # error: [override-of-final-method]
54 | def method4(self) -> None: ... # error: [override-of-final-method]
| ^^^^^^^ Overrides a definition from superclass `A`
|
info: `A.method4` is decorated with `@final`, forbidding overrides
Expand All @@ -310,11 +307,11 @@ info: `A.method4` is decorated with `@final`, forbidding overrides
|
help: Remove the override of `method4`
info: rule `override-of-final-method` is enabled by default
54 |
55 | if coinflip():
56 | def method3(self) -> None: ... # error: [override-of-final-method]
51 |
52 | if coinflip():
53 | def method3(self) -> None: ... # error: [override-of-final-method]
- def method4(self) -> None: ... # error: [override-of-final-method]
57 + # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior
54 + # error: [override-of-final-method]
note: This is a display-only fix and is likely to be incorrect

```
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ info: rule `override-of-final-method` is enabled by default
48 |
49 | @property
50 | def my_property2(self) -> int: ... # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior
note: This is a display-only fix and is likely to be incorrect

```

Expand Down Expand Up @@ -237,7 +237,7 @@ info: rule `override-of-final-method` is enabled by default
51 |
52 | @classmethod
53 | def class_method1(cls) -> int: ... # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior
note: This is a display-only fix and is likely to be incorrect

```

Expand Down Expand Up @@ -465,7 +465,7 @@ info: rule `override-of-final-method` is enabled by default
78 | # TODO: we should emit a Liskov violation here too
79 | # error: [override-of-final-method]
80 | class_method1 = None
note: This is an unsafe fix and may change runtime behavior
note: This is a display-only fix and is likely to be incorrect

```

Expand Down Expand Up @@ -503,7 +503,7 @@ info: rule `override-of-final-method` is enabled by default
84 |
85 | # Diagnostic edge case: `final` is very far away from the method definition in the source code:
86 |
note: This is an unsafe fix and may change runtime behavior
note: This is a display-only fix and is likely to be incorrect

```

Expand Down Expand Up @@ -539,7 +539,7 @@ info: rule `override-of-final-method` is enabled by default
112 |
113 | class Baz(Foo):
- def bar(self): ... # error: [override-of-final-method]
114 + # error: [override-of-final-method]
114 + pass # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior

```
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ info: rule `override-of-final-method` is enabled by default
2 |
3 | class Foo(module1.Foo):
- def f(self): ... # error: [override-of-final-method]
4 + # error: [override-of-final-method]
4 + pass # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior

```
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ info: rule `override-of-final-method` is enabled by default
7 | class B(A):
- @final
- def f(self): ... # error: [override-of-final-method]
8 + # error: [override-of-final-method]
8 + pass # error: [override-of-final-method]
9 |
10 | class C(B):
11 | @final
Expand Down Expand Up @@ -95,7 +95,7 @@ info: rule `override-of-final-method` is enabled by default
- @final
- # we only emit one error here, not two
- def f(self): ... # error: [override-of-final-method]
12 + # error: [override-of-final-method]
12 + pass # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior

```
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/final.md
44 | def bar(self, x: str) -> str: ...
45 | @overload
46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method]
47 |
47 |
48 | @overload
49 | def baz(self, x: str) -> str: ...
50 | @overload
Expand Down Expand Up @@ -265,7 +265,7 @@ error[override-of-final-method]: Cannot override `Bad.bar`
45 | @overload
46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method]
| ^^^ Overrides a definition from superclass `Bad`
47 |
47 |
48 | @overload
|
info: `Bad.bar` is decorated with `@final`, forbidding overrides
Expand All @@ -287,12 +287,11 @@ info: rule `override-of-final-method` is enabled by default
- def bar(self, x: str) -> str: ...
- @overload
- def bar(self, x: int) -> int: ... # error: [override-of-final-method]
43 |
43 +
44 + # error: [override-of-final-method]
45 +
45 |
46 | @overload
47 | def baz(self, x: str) -> str: ...
48 | @overload
note: This is an unsafe fix and may change runtime behavior

```
Expand All @@ -319,7 +318,7 @@ help: Remove all overloads for `baz`
info: rule `override-of-final-method` is enabled by default
45 | @overload
46 | def bar(self, x: int) -> int: ... # error: [override-of-final-method]
47 |
47 |
- @overload
- def baz(self, x: str) -> str: ...
- @overload
Expand Down Expand Up @@ -360,12 +359,12 @@ info: rule `override-of-final-method` is enabled by default
- def f(self, x: str) -> str: ...
- @overload
- def f(self, x: int) -> int: ...
13 +
14 +
13 + pass
14 + pass
15 | # error: [override-of-final-method]
- def f(self, x: int | str) -> int | str:
- return x
16 +
16 + pass
17 |
18 | class Bad:
19 | @overload
Expand Down Expand Up @@ -467,7 +466,7 @@ info: rule `override-of-final-method` is enabled by default
61 | g = None # error: [override-of-final-method]
62 | h = None # error: [override-of-final-method]
63 | i = None # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior
note: This is a display-only fix and is likely to be incorrect

```

Expand Down Expand Up @@ -500,7 +499,7 @@ info: rule `override-of-final-method` is enabled by default
61 + # error: [override-of-final-method]
62 | h = None # error: [override-of-final-method]
63 | i = None # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior
note: This is a display-only fix and is likely to be incorrect

```

Expand Down Expand Up @@ -531,7 +530,7 @@ info: rule `override-of-final-method` is enabled by default
- h = None # error: [override-of-final-method]
62 + # error: [override-of-final-method]
63 | i = None # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior
note: This is a display-only fix and is likely to be incorrect

```

Expand Down Expand Up @@ -560,6 +559,6 @@ info: rule `override-of-final-method` is enabled by default
62 | h = None # error: [override-of-final-method]
- i = None # error: [override-of-final-method]
63 + # error: [override-of-final-method]
note: This is an unsafe fix and may change runtime behavior
note: This is a display-only fix and is likely to be incorrect

```
Loading
Loading