Compare commits

..
1 Commits
Author SHA1 Message Date
Mikaël Capelle 6fe9b1d569 Start working on stubs for 2.6.0 (extensions, etc.). 2024-08-11 13:31:30 +02:00
14 changed files with 4191 additions and 1336 deletions
+2 -2
View File
@@ -34,7 +34,7 @@ jobs:
poetry version ${TAG#v}
poetry build
- name: Store the distribution packages
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: stubs/setup/dist/
@@ -49,7 +49,7 @@ jobs:
steps:
- name: Download all the dists
uses: actions/download-artifact@v7
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
+5 -329
View File
@@ -3,7 +3,7 @@
version: 2
# version of the stubs - this is overridden when publishing
__version__: "2.5.3-beta10"
__version__: "2.5.2"
# This is the root of the mobase module and will contain everything
# related to functions / classes, including their documentation.
@@ -354,66 +354,6 @@ mobase:
The last extension of this entry, or an empty string if the file has no extension
or is directory.
IExecutable:
title:
returns: The title of the executable.
binaryInfo:
returns: The file info of the executable binary.
arguments:
__doc__: |
Retrieve the arguments passed to the executable.
This API might be changed in the future to return a list of strings.
returns: The arguments to be passed to the executable.
steamAppID:
returns: The Steam App ID associated with this executable, or an empty string if there is none.
workingDirectory:
returns: The working directory for the executable.
isShownOnToolbar:
returns: True if the executable is shown on the toolbar.
usesOwnIcon:
returns: True if the executable's application icon is used for desktop shortcuts.
minimizeToSystemTray:
__doc__: |
Check if Mod Organizer should minimize to the system tray while this executable
is running.
returns: True if Mod Organizer should minimize to the system tray while this executable is running.
hide:
returns: True if this executable is hidden in the user interface.
IExecutablesList:
__doc__: Interface to the list of executables configured in Mod Organizer.
executables:
__doc__: Retrieve all configured executables.
returns: A generator yielding all configured executables.
getByTitle:
__doc__: Retrieve an executable by its title.
args:
title: Title of the executable to retrieve.
returns: The executable with the specified title, or `None` if not found.
getByBinary:
__doc__: Retrieve an executable by its binary file info.
args:
info: File info of the executable binary to retrieve.
returns: The executable with the specified binary, or `None` if not found.
contains:
__doc__: Check if an executable with the specified title exists.
args:
title: Title of the executable to check.
returns: True if an executable with the specified title exists, False otherwise.
IGameFeatures:
__doc__: |
Interface for the game features, accessible through IOrganizer.gameFeatures().
@@ -555,8 +495,6 @@ mobase:
returns: True if light plugins are supported, False otherwise.
mediumPluginsAreSupported:
returns: True if medium plugins are supported, False otherwise.
blueprintPluginsAreSupported:
returns: True if blueprint plugins are supported, False otherwise.
readPluginLists:
__doc__:
args:
@@ -657,14 +595,6 @@ mobase:
file_id: ID of the file to download.
returns: An ID identifying the download.
startDownloadNexusFileForGame:
__doc__: Download a file from www.nexusmods.com.
args:
game_name: Short name of the game the mod is for.
mod_id: ID of the mod to download the file from.
file_id: ID of the file to download.
returns: An ID identifying the download.
startDownloadURLs:
__doc__: |
Download a file by url.
@@ -732,15 +662,6 @@ mobase:
root node is destroyed, it will not be possible to go up the tree, even if we still have
a valid shared pointer.
GlobPatternType:
__doc__: |
Enumeration that can defines how the pattern is parsed in IFileTree.glob.
GLOB: Glob pattern, similar to pathlib.Path.glob.
REGEX: |
Regex pattern, i.e., each pattern of the pattern (between / and \) is considered
a regex, except for ** which has the same meaning as GLOB.
InsertPolicy:
__doc__:
FAIL_IF_EXISTS: Operation will fail if the destination already exists.
@@ -882,15 +803,6 @@ mobase:
was not of the correct type.
type: IFileTree | FileTreeEntry | None
glob:
__doc__: Glob entries matching the given pattern in this tree.
args:
pattern: Glob pattern to match.
type: Type of the pattern.
returns:
__doc__: An iterator over entry of this tree matching the given pattern.
type: Iterator[FileTreeEntry]
insert:
__doc__: |
Insert the given entry in this tree, removing it from its
@@ -1013,7 +925,7 @@ mobase:
filter: Predicate that should return true for entries to delete.
returns: The number of deleted entry.
walk.1:
walk:
__doc__: |
Walk this tree, calling the given function for each entry in it.
@@ -1024,53 +936,6 @@ mobase:
callback: Method to call for each entry in the tree.
sep: Type of separator to use to construct the path.
walk.2:
__doc__: |
Walk this tree and return the entries in it.
During the walk, parent tree are guaranteed to be visited before their children.
The current tree is not included in the return generator.
returns:
__doc__: An iterator over entry of this tree.
type: Iterator[FileTreeEntry]
IInstance:
__doc__: Represents a Mod Organizer instance, either global or portable.
displayName:
returns: The instance name; this is the directory name or "Portable" for portable instances.
gameName:
returns: The name of the game managed by this instance, or an empty string if the INI file could not be read.
gameDirectory:
returns: The directory where the game is installed, or an empty string if the INI file could not be read.
isPortable:
returns: True if this is a portable instance, False if it is a global one.
IInstanceManager:
__doc__: Interface to the instance manager of Mod Organizer.
currentInstance:
returns: The current instance.
globalInstancePaths:
__doc__: |
Retrieve the list of absolute paths to all global instances.
This does not include portable instances.
returns: The list of absolute paths to all global instances.
getGlobalInstance:
__doc__: Retrieve the global instance corresponding to the given name.
args:
instanceName: |
Name of the global instance to retrieve. This is the directory
name of the instance.
returns: The global instance corresponding to the given name, or `None` if no such instance exists.
IInstallationManager:
__doc__:
@@ -1136,9 +1001,6 @@ mobase:
absolutePath:
returns: Absolute path to the mod to be used in file system operations.
author:
returns: The author of this mode.
isBackup:
returns: True if this mod represents a backup.
@@ -1212,12 +1074,6 @@ mobase:
color:
returns: The color of the 'Notes' column chosen by the user.
uploader:
returns: The uploader of this mod.
uploaderUrl:
returns: The URL of the uploader of this mod.
url:
returns: |
The URL of this mod, or an empty QString() if no URL is associated
@@ -1698,6 +1554,9 @@ mobase:
getPluginDataPath:
returns: The directory for plugin data, typically plugins/data.
appVersion:
returns: The running version of Mod Organizer.
basePath:
returns: The absolute path to the base directory of Mod Organizer.
@@ -1723,9 +1582,6 @@ mobase:
downloadsPath:
returns: The absolute path to the download directory.
executablesList:
returns: The interface to list of executables.
findFileInfos:
__doc__: Find files in the virtual directory matching the specified filter.
args:
@@ -1773,12 +1629,6 @@ mobase:
name: Name of the game (short name).
returns: The plugin for the given game, or `None` if none was found.
getProfile:
__doc__: Retrieve a profile by name.
args:
name: Name of the profile.
returns: The profile with the specified name or None if no such profile exists.
installMod:
__doc__: Install a mod archive at the specified location.
args:
@@ -1786,17 +1636,6 @@ mobase:
name_suggestion: Suggested name for this mod. This can still be changed by the user.
returns: An interface to the new installed mod, or `None` if no installation took place (canceled or failure).
instanceManager:
returns: The interface to the instance manager.
instanceName:
__doc__: |
Retrieve the name of the current instance.
For global instance, this corresponds to the directory name, for portable
instance this always returns "Portable".
returns: The name of the current instance.
isPluginEnabled.1:
__doc__: Check if a plugin is enabled.
args:
@@ -2012,9 +1851,6 @@ mobase:
profileName:
returns: The name of the current profile, or an empty string if no profile has been loaded (yet).
profileNames:
returns: The names of all existing profiles.
profilePath:
returns: The absolute path to the active profile or an empty string if no profile has been loaded (yet).
@@ -2076,10 +1912,6 @@ mobase:
ignoreCustomOverwrite: Set to true to ignore the profile's configured custom overwrite.
returns: The handle to the started application, or 0 if the application failed to start.
version:
__doc__: Retrieve the running version of MO2.
returns: The running version of MO2.
virtualFileTree:
__doc__: Retrieve a IFileTree object representing the virtual file tree.
returns: An IFileTree representing the virtual file tree.
@@ -2100,8 +1932,6 @@ mobase:
completed successfully, and `exitcode` is the exit code of the application.
# IOrganizer has a bunch of deprecated functions:
appVersion:
deprecated: true
getMod:
deprecated: true
removeMod:
@@ -2299,9 +2129,6 @@ mobase:
binaryName:
returns: The name of the default executable to run (relative to the game folder).
blueprintPrefix:
returns: The blueprint plugin prefix for blueprint auto loading.
dataDirectory:
returns: The path to the directory containing data (absolute path).
@@ -2357,11 +2184,6 @@ mobase:
The name of the launcher executable to run (relative to the game folder), or an
empty string if there is no launcher.
getModMappings:
abstract: false
__doc__: Gets a virtualization mapping for mod directories.
returns:
getSupportURL:
returns: An URL for the support page of this game.
@@ -2408,11 +2230,6 @@ mobase:
returns: |
The game name to use when calling LOOT from MO2, default to gameShortName().
modDataDirectory:
__doc__:
abstract: False
returns:
nexusGameID:
__doc__: |
Retrieve the Nexus game ID for this game.
@@ -2660,42 +2477,6 @@ mobase:
IPluginList:
__doc__: Primary interface to the list of plugins.
author:
__doc__: Retrieve the author of the plugin.
args:
name: Filename of the plugin (without path but with file extension).
returns: The author of the plugin or an empty string if the plugin does not exist.
description:
__doc__: Retrieve the description of the plugin.
args:
name: Filename of the plugin (without path but with file extension).
returns: The description of the plugin or an empty string if the plugin does not exist.
formVersion:
__doc__: Retrieve the form version of the plugin.
args:
name: Filename of the plugin (without path but with file extension).
returns: The form version of the plugin or -1 if the plugin does not exist.
headerVersion:
__doc__: Retrieve the header version of the plugin.
args:
name: Filename of the plugin (without path but with file extension).
returns: The header version of the plugin or -1 if the plugin does not exist.
isBlueprintFlagged:
__doc__: |
Determine if a plugin is flagged as blueprint.
Blueprint plugins were added in Starfield and are plugins that are hidden in
the Creation Kit and removed from plugins.txt on game launch.
args:
name: Filename of the plugin (without path but with file extension).
returns: |
True if the given plugin is a blueprint plugin, False otherwise or if the
file does not exist.
isMaster:
deprecated: True
__doc__: |
@@ -3314,9 +3095,6 @@ mobase:
ModRepositoryFileInfo:
__doc__:
properties[]:
author:
type: str
desc:
categoryID:
type: int
desc:
@@ -3356,12 +3134,6 @@ mobase:
repository:
type: str
desc:
uploader:
type: str
desc:
uploaderUrl:
type: str
desc:
uri:
type: str
desc:
@@ -3509,102 +3281,6 @@ mobase:
mod_name: Internal name of the mod.
returns: The secondary files (absolute paths) for the request mod.
Version:
__doc__: |
Class representing a version objects.
Valid versions are an "extension" of SemVer (see https://semver.org/) with the
following tweaks:
- version can have a sub-patch, i.e., x.y.z.p, which are normally not allowed by
SemVer,
- non-integer pre-release identifiers are limited to dev, alpha (a), beta (b) and rc,
and dev is lower than alpha (according to SemVer, the pre-release should be
ordered alphabetically),
- the '-' between version and pre-release can be made optional, and also the '.'
between pre-releases segment.
The extension from SemVer are only meant to be used by MO2 and USVFS versioning,
plugins and extensions should follow SemVer standard (and not use dev), this is
mainly
- for back-compatibility purposes, because USVFS versioning contains sub-patches and
there are old MO2 releases with sub-patch,
- because MO2 is not going to become MO3, so having an extra level make sense.
Unlike VersionInfo, this class is immutable and only hold valid versions.
ParseMode:
__doc__: Enumeration defining how to parse version from string.
SEMVER: Official semver parsing with pre-release limited to dev, alpha/a, beta/b and rc.
MO2: |
MO2 parsing, e.g., 2.5.1rc1 - this either parse a string with no pre-release
information (e.g. 2.5.1) or with a single pre-release + a version (e.g., 2.5.1a1
or 2.5.2rc1).
This mode can parse sub-patch (SemVer mode cannot).
FormatMode:
__doc__: Enumeration defining how to format version into string.
FORCE_SUBPATCH: Show sub-patch even if sub-patch is 0.
NO_SEPARATOR: |
Do not add separators between version and pre-release (-) or between pre-release
segments (.).
SHORT_ALPHA_BETA: Use short form for alpha and beta (a/b instead of alpha/beta).
NO_METADATA: Do not add metadata even if present.
CONDENSED: Condensed format, combination of NO_SEPARATOR, SHORT_ALPHA_BETA and NO_METADATA.
ReleaseType:
__doc__: Enumeration representing the release type of a version.
DEVELOPMENT:
ALPHA:
BETA:
RELEASE_CANDIDATE:
properties[]:
major:
type: int
desc: The major component of this version.
minor:
type: int
desc: The minor component of this version.
patch:
type: int
desc: The patch component of this version.
subpatch:
type: int
desc: The sub-patch component of this version.
prereleases:
type: list[int | ReleaseType]
desc: The pre-release components of this version.
build_metadata:
type: str
desc: The build-metadata component of this version, or an empty string.
isPreRelease:
__doc__: Check if this version represents a pre-release version.
returns: True if this version is a pre-release version, False otherwise.
parse:
__doc__: |
Parse version from the given string, throw InvalidVersionException if the
string cannot be parsed.
static: True
args:
value: Value to parse.
mode: Mode to use when parsing, see ParseMode for more details.
returns: The parsed version.
string:
__doc__: Convert this version to a string.
args:
mode: Combination of modes to use creating the string, see FormatMode.
returns: A string representing this version according to the given modes.
VersionInfo:
__doc__: Represents the version of a mod or plugin.
File diff suppressed because it is too large Load Diff
Generated
+388 -462
View File
File diff suppressed because it is too large Load Diff
+29 -31
View File
@@ -1,39 +1,37 @@
[project]
name = "mo2-pystubs-generation"
description = ""
license = "MIT"
version = "0.1.0"
readme = "README.md"
authors = [{ name = "Holt59", email = "capelle.mikael@gmail.com" }]
requires-python = ">=3.12,<4.0"
dependencies = [
"pyqt6 (==6.11.0)",
"pyyaml (>=6.0.3,<7.0.0)",
"typing-extensions (>=4.15.0,<5.0.0)",
]
[project.scripts]
mo2-stubs-generator = "mo2.stubs.generator.__main__:main"
[build-system]
requires = ['poetry-core (>=2.0,<3.0)']
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "mo2-pystubs-generation"
version = "0.1.0"
description = ""
authors = ["Holt59 <capelle.mikael@gmail.com>"]
license = "MIT"
readme = "README.md"
packages = [{ include = "mo2", from = "src" }]
[tool.poetry.scripts]
mo2-stubs-generator = "mo2.stubs.generator.__main__:main"
[tool.poetry.dependencies]
python = "^3.12"
pyqt6 = "6.7.1"
pyyaml = "^6.0.1"
typing-extensions = "^4.12.2"
[tool.poetry.group.dev.dependencies]
pyright = "^1.1.409"
ruff = "^0.15.12"
types-pyyaml = "^6.0.12.20260508"
poethepoet = "^0.45.0"
pyright = "^1.1.374"
ruff = "^0.5.5"
types-pyyaml = "^6.0.12.20240724"
poethepoet = "^0.27.0"
[tool.poetry.group.doc.dependencies]
sphinx-rtd-theme = "^3.0.2"
sphinx-autodoc-typehints = "^3.2.0"
sphinx-automodapi = "^0.20.0"
sphinx = "^8.2.3"
sphinx-autoapi = "^3.6.0"
sphinx-rtd-theme = "^2.0.0"
sphinx-autodoc-typehints = "^2.2.3"
sphinx-automodapi = "^0.17.0"
sphinx = "<8"
sphinx-autoapi = "^3.2.1"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poe.tasks]
format-imports = "ruff check --select I src --fix"
@@ -46,7 +44,7 @@ lint.sequence = ["lint-ruff", "lint-ruff-format", "lint-pyright"]
lint.ignore_fail = "return_non_zero"
[tool.ruff]
target-version = "py312"
target-version = "py310"
[tool.ruff.lint]
extend-select = ["B", "Q", "I"]
+12 -5
View File
@@ -12,15 +12,15 @@ from .mtypes import Class, Constant, Enum, Function, PyTyping
from .parser import is_enum
from .register import MobaseRegister
from .utils import Settings, clean_class
from .writer import Writer, is_list_of
from .writer import Writer, is_list_of_functions
LOGGER = logging.getLogger(__package__)
def extract_objects(
module: object, skips: Sequence[str] = []
) -> list[tuple[str, object]]:
objects: list[tuple[str, object]] = []
) -> list[tuple[str, type]]:
objects: list[tuple[str, type]] = []
assert hasattr(module, "__name__")
module_name: str = module.__name__ # type: ignore
@@ -140,12 +140,15 @@ def main() -> None:
}
# list of objects directly in mobase
module_objects: dict[str, list[tuple[str, object]]] = {
module_objects: dict[str, list[tuple[str, type]]] = {
"mobase": extract_objects(
mobase,
[
# the "real" IPlugin is IPluginBase
"IPlugin",
# this is deprecated
"PluginSetting"
],
),
"mobase.widgets": extract_objects(mobase.widgets), # type: ignore
@@ -171,6 +174,10 @@ def main() -> None:
# Create the corresponding object:
c = register.make_object(n, o)
for n, o in objects:
c = register.get_object(n)
if isinstance(c, Class):
# Clean the class (e.g., remove duplicates methods due to wrappers):
clean_class(c)
@@ -181,7 +188,7 @@ def main() -> None:
elif isinstance(c, (PyTyping, Constant)):
...
elif is_list_of(c, Function):
elif is_list_of_functions(c):
settings.patch_functions(c)
else:
+1 -1
View File
@@ -33,7 +33,7 @@ def load_mobase(path: os.PathLike[Any]) -> Module:
os.add_dll_directory(str(path.joinpath("dlls"))) # type: ignore
# We need to add plugins/data to sys.path, mainly for PyQt6
sys.path.insert(1, path.joinpath("plugins", "plugin_python", "libs").as_posix())
sys.path.insert(1, path.joinpath("proxies", "python", "libs").as_posix())
import mobase # type: ignore
+15 -16
View File
@@ -4,7 +4,7 @@ import re
import types
from collections import OrderedDict, defaultdict
from itertools import chain
from typing import Any, Callable, Iterable, cast
from typing import Any, Iterable, cast
from .mtypes import (
Argument,
@@ -118,7 +118,7 @@ def parse_python_signature(s: str, name: str) -> tuple[PyType, list[Argument]]:
return PyType(return_type), arguments
def is_enum(e: object) -> bool:
def is_enum(e: type) -> bool:
"""Check if the given class is an enumeration.
Args:
@@ -144,18 +144,17 @@ class Overload:
self.arguments = arguments
def parse_pybind11_function_docstring(name: str, doc: str | None) -> list[Overload]:
def parse_pybind11_function_docstring(e: type) -> list[Overload]:
"""
Parse the docstring of a Pybind11 function.
Parse the docstring of the given element.
Args:
name: Name of the function.
doc: The docstring of the function generated by Pybind11.
e: The function to "parse".
Returns:
A list of overloads for the given function.
"""
lines = (doc or "").strip().split("\n")
lines = (e.__doc__ or "").strip().split("\n")
signatures: list[str]
if len(lines) == 1:
@@ -163,7 +162,7 @@ def parse_pybind11_function_docstring(name: str, doc: str | None) -> list[Overlo
else:
signatures = []
for line in lines:
m = re.match(rf"^[0-9]+[.]\s+({name}.*)$", line)
m = re.match(rf"^[0-9]+[.]\s+({e.__name__}.*)$", line)
if m:
signatures.append(m.group(1).strip())
@@ -175,16 +174,16 @@ def parse_pybind11_function_docstring(name: str, doc: str | None) -> list[Overlo
signature = signature.replace("MOBase::", "mobase.").replace("::", ".")
try:
return_type, arguments = parse_python_signature(signature, name)
return_type, arguments = parse_python_signature(signature, e.__name__)
except ValueError as err:
raise ValueError(f"invalid signature: {name}, {doc}") from err
raise ValueError(f"invalid signature: {e.__name__}, {e.__doc__}") from err
overloads.append(Overload(return_type=return_type, arguments=arguments))
return overloads
def make_functions(e: Callable[..., Any]) -> list[Function]:
overloads = parse_pybind11_function_docstring(e.__name__, e.__doc__)
def make_functions(e: type) -> list[Function]:
overloads = parse_pybind11_function_docstring(e)
return [
Function(
@@ -235,6 +234,8 @@ def make_class(e: type, register: MobaseRegister) -> Class:
# members to exclude
EXCLUDED_MEMBERS = [
"__init_subclass__",
"__dict__",
"__doc__",
"__module__",
"__subclasshook__",
"__hash__",
@@ -296,9 +297,7 @@ def make_class(e: type, register: MobaseRegister) -> Class:
# otherwise we parse the docstring
else:
overloads = parse_pybind11_function_docstring(
method.__name__, method.__doc__
)
overloads = parse_pybind11_function_docstring(method)
for overload in overloads:
args = overload.arguments
@@ -349,7 +348,7 @@ def make_class(e: type, register: MobaseRegister) -> Class:
direct_bases: list[Class] = []
for c in e.__bases__:
if c.__module__ != "pybind11_builtins":
if c.__module__ not in ("pybind11_builtins", "builtins"):
b = register.get_object(c.__name__)
assert isinstance(b, Class)
direct_bases.append(b)
+4 -4
View File
@@ -15,14 +15,14 @@ class MobaseRegister:
objects: dict[str, Class | Constant | list[Function] | PyTyping]
def __init__(self) -> None:
self.raw_objects: dict[str, object] = OrderedDict()
self.raw_objects: dict[str, type] = OrderedDict()
self.objects = {}
def add_object(self, n: str, o: object, /) -> None:
self.raw_objects[n] = o
def add_object(self, name: str, object: type) -> None:
self.raw_objects[name] = object
def make_object(
self, name: str, e: object | None = None
self, name: str, e: type | None = None
) -> Class | list[Function] | Constant | PyTyping:
"""
Construct a Function, Class, Constant or Enum for the given object.
+9 -9
View File
@@ -215,7 +215,7 @@ class Settings:
# Check the args:
if function_settings.args is not None:
if len(function_settings.args) != len(fn.args):
LOGGER.warning(
LOGGER.warn(
f"Mismatch number of arguments for function "
f"mobase.{setting_name}."
)
@@ -243,7 +243,7 @@ class Settings:
fn.deprecated = function_settings.deprecated
else:
LOGGER.warning(
LOGGER.warn(
"Missing settings for function mobase.{}.".format(setting_name)
)
@@ -268,7 +268,7 @@ class Settings:
class_settings = self._get_class_settings(cls.canonical_name)
if class_settings is None:
LOGGER.warning("Class {} not found in settings.".format(cls.canonical_name))
LOGGER.warn("Class {} not found in settings.".format(cls.canonical_name))
return
if "__doc__" in class_settings and class_settings["__doc__"] is not None:
@@ -306,7 +306,7 @@ class Settings:
if "type" in settings_property:
prop.type = PyType(settings_property["type"])
else:
LOGGER.warning(
LOGGER.warn(
"Missing type for property {}.{}.".format(
cls.canonical_name, prop.name
)
@@ -320,7 +320,7 @@ class Settings:
prop.doc = settings_property["desc"]
else:
LOGGER.warning(
LOGGER.warn(
"Missing description for property {}.{}.".format(
cls.canonical_name, prop.name
)
@@ -366,7 +366,7 @@ class Settings:
if function_settings.args is not None:
method_arguments = m.args if m.is_static() else m.args[1:]
if len(function_settings.args) != len(method_arguments):
LOGGER.warning(
LOGGER.warn(
"Mismatch number of arguments for method {}.{}.".format(
cls.canonical_name, settings_name
)
@@ -380,7 +380,7 @@ class Settings:
not method_arg.name.startswith("arg")
and method_arg.name != settings_arg.name
):
LOGGER.warning(
LOGGER.warn(
(
"Mismatch argument name for method {}.{}: "
"{} {}, using {}."
@@ -429,7 +429,7 @@ class Settings:
if n_overloads > 0 and missing_settings:
for settings_name in missing_settings:
LOGGER.warning(
LOGGER.warn(
"Missing settings for method {}.{}.".format(
cls.canonical_name, settings_name
)
@@ -447,7 +447,7 @@ class Settings:
# Print items missing in mobase
missing_items = [k for k, v in keys.items() if not v]
if missing_items:
LOGGER.warning(
LOGGER.warn(
"The following members were found in settings but not in the actual"
" class {}: {}.".format(cls.canonical_name, ", ".join(missing_items))
)
+6 -8
View File
@@ -1,5 +1,5 @@
import logging
from typing import Any, TextIO
from typing import Any, Iterable, TextIO
from typing_extensions import TypeIs
@@ -9,12 +9,10 @@ from .utils import Settings
LOGGER = logging.getLogger(__package__)
def is_list_of_any(e: Any) -> TypeIs[list[Any]]:
return isinstance(e, list)
def is_list_of[T](e: Any, t: type[T]) -> TypeIs[list[T]]:
return is_list_of_any(e) and all(isinstance(x, t) for x in e)
def is_list_of_functions(e: Any | Iterable[Any]) -> TypeIs[list[Function]]:
if not isinstance(e, list):
return False
return all(isinstance(x, Function) for x in e)
class Writer:
@@ -272,7 +270,7 @@ class Writer:
if isinstance(e, Class):
self.print_class(e)
elif is_list_of(e, Function):
elif is_list_of_functions(e):
for fn in e:
self.print_function(fn)
File diff suppressed because it is too large Load Diff
@@ -1,6 +1,6 @@
from __future__ import annotations
__version__ = "2.5.3-beta10"
__version__ = "2.5.2"
from typing import List, Tuple, Union, overload
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mobase-stubs"
version = "2.5.3.beta-2"
version = "v2.5.0.dev17"
description = "PEP561 stub files for the mobase Python API."
authors = ["Holt59 <capelle.mikael@gmail.com>"]
license = "MIT"