Skip to content

Commit 951ef32

Browse files
authored
Ensure @OverRide is added to every overriding method/property (#74)
Add @OverRide decorators and make mypy check for missing override decorators
1 parent 1e960ff commit 951ef32

13 files changed

+360
-7
lines changed

experimentation.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import override
2+
3+
4+
class Base:
5+
def some_method(self) -> str:
6+
return "This is a method from the Base class."
7+
8+
9+
class Sub(Base):
10+
def some_method(self) -> str:
11+
return "This is a method from the Sub class."
12+
13+
@override
14+
def some_methods(self) -> str:
15+
return "This is a method from the Sub class."

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ testing = [
4646
"typing_extensions"
4747
]
4848

49+
[tool.mypy]
50+
enable_error_code = "explicit-override"
4951

5052
[tool.setuptools.packages.find]
5153
where = ["src"]

0 commit comments

Comments
 (0)