Skip to content

Commit

Permalink
Fix missing optional annotation in some cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Sep 23, 2023
1 parent 962a3c2 commit 4fa50f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/mo2/stubs/generator/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ def parse_python_signature(s: str, name: str) -> tuple[PyType, list[Argument]]:
raise ValueError(f"invalid argument: {pa}, {s}")

matches = m.groupdict()
arguments.append(
Argument(matches["name"], PyType(matches["type"]), matches["value"])
)
type_ = matches["type"]
if matches["value"] == "None":
if "None" not in type_ and "MoVariant" not in type_:
type_ = type_ + " | None"

arguments.append(Argument(matches["name"], PyType(type_), matches["value"]))

return PyType(return_type), arguments

Expand Down
4 changes: 2 additions & 2 deletions stubs/2.5.0/mobase-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ class IModList:
"""
...
def allModsByProfilePriority(
self: IModList, profile: IProfile = None
self: IModList, profile: IProfile | None = None
) -> Sequence[str]:
"""
Returns:
Expand Down Expand Up @@ -3818,7 +3818,7 @@ class ISaveGameInfoWidget(PyQt6.QtWidgets.QWidget):
"""

def __init__(
self: ISaveGameInfoWidget, parent: PyQt6.QtWidgets.QWidget = None
self: ISaveGameInfoWidget, parent: PyQt6.QtWidgets.QWidget | None = None
) -> None:
"""
Args:
Expand Down
2 changes: 1 addition & 1 deletion stubs/2.5.0/mobase-stubs/widgets/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TaskDialog:

def __init__(
self: TaskDialog,
parent: PyQt6.QtWidgets.QWidget = None,
parent: PyQt6.QtWidgets.QWidget | None = None,
title: str = "",
main: str = "",
content: str = "",
Expand Down

0 comments on commit 4fa50f8

Please sign in to comment.