From 2fcaa7ce5018128fc534ff53d31cc902a9f7290e Mon Sep 17 00:00:00 2001 From: Christopher O'Brien Date: Fri, 22 Sep 2023 17:32:41 -0400 Subject: [PATCH] added some more definitions to the stub, and fixed ordering --- stubs/koji/__init__.pyi | 544 ++++++++++++++++++++++------------------ 1 file changed, 298 insertions(+), 246 deletions(-) diff --git a/stubs/koji/__init__.pyi b/stubs/koji/__init__.pyi index 13ddc2a3..aeaf4913 100644 --- a/stubs/koji/__init__.pyi +++ b/stubs/koji/__init__.pyi @@ -28,8 +28,8 @@ calls are being used correctly. from configparser import ConfigParser, RawConfigParser from datetime import datetime from typing import ( - Any, Dict, List, Optional, Tuple, TypedDict, TypeVar, Union, Set, - overload, ) + Any, Dict, Iterable, List, Optional, Tuple, TypedDict, TypeVar, + Union, Set, overload, ) from xmlrpc.client import DateTime from kojismokydingo.types import ( @@ -40,60 +40,46 @@ from kojismokydingo.types import ( TagPackageInfo, TargetInfo, TaskInfo, UserInfo, ) -AUTHTYPE_NORMAL: int +# === Globals === + +BASEDIR: str + +AUTHTYPE_GSSAPI: int AUTHTYPE_KERB: int +AUTHTYPE_NORMAL: int AUTHTYPE_SSL: int -AUTHTYPE_GSSAPI: int -REPO_INIT: int -REPO_READY: int -REPO_EXPIRED: int +PRIO_DEFAULT: int + REPO_DELETED: int -REPO_PROBLEM: int +REPO_EXPIRED: int +REPO_INIT: int REPO_MERGE_MODES: Set[str] +REPO_PROBLEM: int +REPO_READY: int RPM_SIGTAG_GPG: int +RPM_SIGTAG_MD5: int RPM_SIGTAG_PGP: int RPM_SIGTAG_RSA: int -RPM_SIGTAG_MD5: int -RPM_TAG_HEADERSIGNATURES: int RPM_TAG_FILEDIGESTALGO: int +RPM_TAG_HEADERSIGNATURES: int -PRIO_DEFAULT: int - -BASEDIR: str - - -class Enum(dict): - def getnum(self, key: Union[str, int]) -> int: - ... - - -BR_STATES: Enum -BR_TYPES: Enum -BUILD_STATES: Enum -CHECKSUM_TYPES: Enum -REPO_STATES: Enum -TAG_UPDATE_TYPES: Enum -TASK_STATES: Enum -USERTYPES: Enum -USER_STATUS: Enum - - -class Fault: - def __init__( - self, - faultCode: int, - faultString: str, - **extra: Any): - ... +BR_STATES: "Enum" +BR_TYPES: "Enum" +BUILD_STATES: "Enum" +CHECKSUM_TYPES: "Enum" +REPO_STATES: "Enum" +TAG_UPDATE_TYPES: "Enum" +TASK_STATES: "Enum" +USERTYPES: "Enum" +USER_STATUS: "Enum" +pathinfo: "PathInfo" -class FaultInfo(TypedDict): - faultCode: int - faultString: str +# === Exceptions === class GenericError(Exception): faultCode: int @@ -104,156 +90,65 @@ class ActionNotAllowed(GenericError): ... -class AuthError(GenericError): +class ApplianceError(GenericError): ... -class BuildError(GenericError): +class AuthError(GenericError): ... -class BuildrootError(BuildError): +class AuthExpired(AuthError): ... -class ParameterError(GenericError): +class AuthLockError(AuthError): ... -class ConfigurationError(GenericError): +class BuildError(GenericError): ... -class LockError(GenericError): +class BuildrootError(BuildError): ... -class AuthExpired(AuthError): +class ConfigurationError(GenericError): ... -class AuthLockError(AuthError): +class LiveCDError(GenericError): ... -class RetryError(AuthError): +class LiveMediaError(GenericError): ... -class TagError(GenericError): +class LockError(GenericError): ... -class LiveMediaError(GenericError): +class ParameterError(GenericError): ... -class ApplianceError(GenericError): +class RetryError(AuthError): ... -class LiveCDError(GenericError): +class TagError(GenericError): ... -class PathInfo: - topdir: str - - def __init__( - self, - topdir: str = None): - ... - - def build( - self, - build: BuildInfo) -> str: - ... - - def build_logs( - self, - build: BuildInfo) -> str: - ... - - def distrepo( - self, - repo_id: int, - tag: TagInfo, - volume: str = None) -> str: - ... - - def imagebuild( - self, - build: BuildInfo) -> str: - ... - - def mavenbuild( - self, - build: BuildInfo) -> str: - ... - - def mavenfile( - self, - maveninfo: ArchiveInfo) -> str: - ... - - def repo( - self, - repo_id: int, - tag_str: str) -> str: - ... - - def rpm( - self, - rpminfo: RPMInfo) -> str: - ... - - def sighdr( - self, - rinfo: RPMInfo, - sigkey: str) -> str: - ... - - def signed( - self, - rpminfo: RPMInfo, - sigkey: str) -> str: - ... - - def taskrelpath( - self, - task_id: int) -> str: - ... - - def typedir( - self, - build: BuildInfo, - btype: str) -> str: - ... - - def winbuild( - self, - build: BuildInfo) -> str: - ... - - def winfile( - self, - wininfo: ArchiveInfo) -> str: - ... - - def work( - self, - volume=Optional[str]) -> str: - ... - - -pathinfo: PathInfo - +# === Classes === class ClientSession: baseurl: str - opts: Dict[str, Any] multicall: bool + opts: Dict[str, Any] def __init__( self, @@ -281,12 +176,22 @@ class ClientSession: extra: Optional[Dict[str, str]] = None) -> int: ... + def disableUser( + self, + username: Union[int, str]) -> None: + ... + def editTag2( self, taginfo: Union[int, str], **kwargs) -> None: ... + def enableUser( + self, + username: Union[int, str]) -> None: + ... + def exclusiveSession(self, *args, **kwargs) -> None: ... @@ -357,12 +262,6 @@ class ClientSession: reverse: bool = False) -> TagInheritance: ... - def getInheritanceData( - self, - tag: Union[int, str], - event: Optional[int] = None) -> TagInheritance: - ... - def getGroupMembers( self, group: Union[int, str]) -> List[UserInfo]: @@ -375,6 +274,12 @@ class ClientSession: event: Optional[int] = None) -> HostInfo: ... + def getInheritanceData( + self, + tag: Union[int, str], + event: Optional[int] = None) -> TagInheritance: + ... + def getKojiVersion(self) -> str: """ :since: koji 1.23 @@ -459,6 +364,13 @@ class ClientSession: incl_blocked: bool = False) -> List[TagGroupInfo]: ... + def getTaskChildren( + self, + task_id: int, + request: Optional[bool] = False, + strict: Optional[bool] = False) -> List[TaskInfo]: + ... + @overload def getTaskInfo( self, @@ -475,13 +387,6 @@ class ClientSession: strict: bool = False) -> List[TaskInfo]: ... - def getTaskChildren( - self, - task_id: int, - request: Optional[bool] = False, - strict: Optional[bool] = False) -> List[TaskInfo]: - ... - def getUser( self, userInfo: Optional[Union[int, str]] = None, @@ -491,7 +396,13 @@ class ClientSession: def getUserPerms( self, - userID: Optional[Union[int, str]] = None) -> List[str]: + userID: Optional[Union[int, str]] = None, + with_groups: bool = True) -> List[str]: + ... + + def getUserPermsInheritance( + self, + userID: Union[int, str]) -> Dict[str, List[str]]: ... def gssapi_login( @@ -502,6 +413,12 @@ class ClientSession: proxyuser: Optional[str] = None) -> bool: ... + def hasPerm( + self, + perm: str, + strict: bool = False) -> bool: + ... + def listArchives( self, buildID: Optional[int] = None, @@ -562,6 +479,13 @@ class ClientSession: queryOpts: Optional[QueryOptions] = None) -> List[RPMInfo]: ... + def listUsers( + self, + userType: int = 0, + prefix: Optional[str] = None, + queryOpts: Optional[QueryOptions] = None) -> List[UserInfo]: + ... + def listTagged( self, tag: Union[int, str], @@ -705,36 +629,131 @@ class ClientSession: ... -def convertFault(fault: Fault) -> GenericError: - ... +class Enum(dict): + def __init__( + self, + args: Iterable[str]): + ... + @overload + def get(self, + key: int, + default: Any = None) -> Optional[str]: + ... -def read_config( - profile_name: str, - user_config: Optional[str] = None) -> Dict[str, Any]: - ... + @overload + def get(self, + key: str, + default: Any = None) -> Optional[int]: + ... + def getnum(self, + key: Union[str, int]) -> int: + ... -def read_config_files( - config_files: List[Union[str, Tuple[str, bool]]], - raw: bool = False) -> Union[ConfigParser, RawConfigParser]: - ... +class Fault: + def __init__( + self, + faultCode: int, + faultString: str, + **extra: Dict[str,Any]): + ... -def hex_string(s: str) -> str: - ... +class FaultInfo(TypedDict): + faultCode: int + faultString: str -def load_json(filepath: str) -> Any: - ... +class PathInfo: + topdir: str -def dump_json( - filepath: str, - data: Any, - indent: int = 4, - sort_keys: bool = False) -> None: - ... + def __init__( + self, + topdir: Optional[str] = None): + ... + + def build( + self, + build: BuildInfo) -> str: + ... + + def build_logs( + self, + build: BuildInfo) -> str: + ... + + def distrepo( + self, + repo_id: int, + tag: TagInfo, + volume: Optional[str] = None) -> str: + ... + + def imagebuild( + self, + build: BuildInfo) -> str: + ... + + def mavenbuild( + self, + build: BuildInfo) -> str: + ... + + def mavenfile( + self, + maveninfo: ArchiveInfo) -> str: + ... + + def repo( + self, + repo_id: int, + tag_str: str) -> str: + ... + + def rpm( + self, + rpminfo: RPMInfo) -> str: + ... + + def sighdr( + self, + rinfo: RPMInfo, + sigkey: str) -> str: + ... + + def signed( + self, + rpminfo: RPMInfo, + sigkey: str) -> str: + ... + + def taskrelpath( + self, + task_id: int) -> str: + ... + + def typedir( + self, + build: BuildInfo, + btype: str) -> str: + ... + + def winbuild( + self, + build: BuildInfo) -> str: + ... + + def winfile( + self, + wininfo: ArchiveInfo) -> str: + ... + + def work( + self, + volume=Optional[str]) -> str: + ... class RawHeader: @@ -749,40 +768,39 @@ class RawHeader: ... -def check_NVR( - nvr: Union[str, Dict[str, Union[str, int]]], - strict: bool = False) -> bool: - ... - +# === Functions === -def parse_NVR(nvr: str) -> Dict[str, Union[str, int]]: +def _fix_print( + value: Union[str, bytes]) -> str: ... -def parse_NVRA(nvra: str) -> Dict[str, Union[str, int]]: +def _open_text_file( + path: str, + mode: str = 'rt'): ... -def get_sigpacket_key_id( - sigpacket: str) -> str: +def add_file_logger( + logger: str, + fn: str) -> None: ... -def ensuredir( - directory: str) -> None: +def add_mail_logger( + logger: str, + addr: str) -> None: ... -def grab_session_options( - options: Union[Dict[str, Any], Any]) -> Dict[str, Any]: +def add_stderr_logger( + logger: str) -> None: ... -def parse_arches( - arches: str, - to_list: bool = False, - strict: bool = False, - allow_none: bool = False) -> Union[List[str], str]: +def buildLabel( + buildInfo: BuildInfo, + showEpoch: bool = False) -> str: ... @@ -791,38 +809,59 @@ def canonArch( ... -def is_debuginfo( - name: str) -> bool: +def check_NVR( + nvr: Union[str, Dict[str, Union[str, int]]], + strict: bool = False) -> bool: ... -def _fix_print( - value: Union[str, bytes]) -> str: +def convertFault(fault: Fault) -> GenericError: ... -def _open_text_file( - path: str, - mode: str = 'rt'): +def daemonize() -> None: ... -def formatTime( - value: Union[int, float, datetime, DateTime]) -> str: +def dump_json( + filepath: str, + data: Any, + indent: int = 4, + sort_keys: bool = False) -> None: ... -def openRemoteFile( - relpath: str, - topurl: Optional[str], - topdir: Optional[str], - tempdir: Optional[str]): +def ensuredir( + directory: str) -> None: ... -def get_rpm_headers( - f: Any, - ts: Optional[int] = None) -> bytes: +def fixEncoding( + value: Any, + fallback: str = 'iso8859-15', + remove_nonprintable: bool = False) -> str: + ... + + +def fix_encoding( + value: str, + fallback: str = 'iso8859-15', + remove_nonprintable: bool = False) -> str: + ... + + +def formatTime( + value: Union[int, float, datetime, DateTime]) -> str: + ... + + +def genMockConfig( + name: str, + arch: str, + managed: bool = True, + repoid: Optional[int] = None, + tag_name: Optional[str] = None, + **opts) -> str: ... @@ -846,61 +885,74 @@ def get_rpm_header( ... -def maven_info_to_nvr( - maveninfo: Dict[str, Any]) -> Dict[str, Any]: +def get_rpm_headers( + f: Any, + ts: Optional[int] = None) -> bytes: ... -def genMockConfig( - name: str, - arch: str, - managed: bool = True, - repoid: Optional[int] = None, - tag_name: Optional[str] = None, - **opts) -> str: +def get_sigpacket_key_id( + sigpacket: str) -> str: ... -def buildLabel( - buildInfo: BuildInfo, - showEpoch: bool = False) -> str: +def grab_session_options( + options: Union[Dict[str, Any], Any]) -> Dict[str, Any]: ... -def fixEncoding( - value: Any, - fallback: str = 'iso8859-15', - remove_nonprintable: bool = False) -> str: +def hex_string(s: str) -> str: ... -def fix_encoding( - value: str, - fallback: str = 'iso8859-15', - remove_nonprintable: bool = False) -> str: +def is_debuginfo( + name: str) -> bool: ... -def add_file_logger( - logger: str, - fn: str) -> None: +def load_json(filepath: str) -> Any: ... -def add_mail_logger( - logger: str, - addr: str) -> None: +def maven_info_to_nvr( + maveninfo: Dict[str, Any]) -> Dict[str, Any]: ... -def add_stderr_logger( - logger: str) -> None: +def openRemoteFile( + relpath: str, + topurl: Optional[str], + topdir: Optional[str], + tempdir: Optional[str]): ... -def daemonize() -> None: +def parse_NVR(nvr: str) -> Dict[str, Union[str, int]]: + ... + + +def parse_NVRA(nvra: str) -> Dict[str, Union[str, int]]: + ... + + +def parse_arches( + arches: str, + to_list: bool = False, + strict: bool = False, + allow_none: bool = False) -> Union[str, List[str]]: + ... + + +def read_config( + profile_name: str, + user_config: Optional[str] = None) -> Dict[str, Any]: + ... + + +def read_config_files( + config_files: List[Union[str, Tuple[str, bool]]], + raw: bool = False) -> Union[RawConfigParser, ConfigParser]: ... -# # The end.