8000 Improve `pywin32.isapi` by donBarbos · Pull Request #13889 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Improve pywin32.isapi #13889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 4 additions & 6 deletions stubs/pywin32/isapi/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from _typeshed import Incomplete

class ISAPIError(Exception):
errno: Incomplete
strerror: Incomplete
funcname: Incomplete
def __init__(self, errno, strerror: Incomplete | None = None, funcname: Incomplete | None = None) -> None: ...
errno: int
strerror: str | None
funcname: str | None
def __init__(self, errno: int, strerror: str | None = None, funcname: str | None = None) -> None: ...

class FilterError(ISAPIError): ...
class ExtensionError(ISAPIError): ...
Expand Down
45 changes: 24 additions & 21 deletions stubs/pywin32/isapi/install.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsGetItem, Unused
from collections.abc import Callable, Iterable, Mapping
from optparse import OptionParser
from typing import Final, Literal

this_dir: Incomplete
this_dir: str

class FilterParameters:
Name: Incomplete
Expand Down Expand Up @@ -33,8 +36,8 @@ class VirtualDirParameters:
ScriptMapUpdate: str
Server: Incomplete
def __init__(self, **kw) -> None: ...
def is_root(self): ...
def split_path(self): ...
def is_root(self) -> bool: ...
def split_path(self) -> list[str]: ...

class ScriptMapParams:
Extension: Incomplete
Expand All @@ -56,43 +59,43 @@ class ISAPIParameters:

verbose: int

def log(level, what) -> None: ...
def log(level: int, what: object) -> None: ...

class InstallationError(Exception): ...
class ItemNotFound(InstallationError): ...
class ConfigurationError(InstallationError): ...

def FindPath(options, server, name): ...
def LocateWebServerPath(description): ...
def GetWebServer(description: Incomplete | None = None): ...
def FindPath(options, server: str | bytes | bytearray, name: str) -> str: ...
def LocateWebServerPath(description: str): ...
def GetWebServer(description: str | None = None): ...
def LoadWebServer(path): ...
def FindWebServer(options, server_desc): ...
def split_path(path): ...
def FindWebServer(options, server_desc: str | bytes | bytearray | None) -> str: ...
def split_path(path: str) -> list[str]: ...
def CreateDirectory(params, options): ...
def AssignScriptMaps(script_maps, target, update: str = "replace") -> None: ...
def AssignScriptMaps(script_maps: Iterable[ScriptMapParams], target, update: str = "replace") -> None: ...
def get_unique_items(sequence, reference): ...
def CreateISAPIFilter(filterParams, options): ...
def DeleteISAPIFilter(filterParams, options) -> None: ...
def AddExtensionFiles(params, options) -> None: ...
def DeleteExtensionFileRecords(params, options) -> None: ...
def CheckLoaderModule(dll_name) -> None: ...
def CheckLoaderModule(dll_name: StrOrBytesPath) -> None: ...
def Install(params, options) -> None: ...
def RemoveDirectory(params, options) -> None: ...
def RemoveScriptMaps(vd_params, options) -> None: ...
def Uninstall(params, options) -> None: ...
def GetLoaderModuleName(mod_name, check_module: Incomplete | None = None): ...
def InstallModule(conf_module_name, params, options, log=...) -> None: ...
def UninstallModule(conf_module_name, params, options, log=...) -> None: ...
def GetLoaderModuleName(mod_name: StrPath, check_module: bool | None = None) -> str: ...
def InstallModule(conf_module_name: StrPath, params, options, log: Callable[[int, str], Unused] = ...) -> None: ...
def UninstallModule(conf_module_name: StrPath, params, options, log: Callable[[int, str], Unused] = ...) -> None: ...
Comment on lines +87 to +88
Copy link
Contributor Author
@donBarbos donBarbos Apr 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be sync with the log function?

Suggested change
def InstallModule(conf_module_name: StrPath, params, options, log: Callable[[int, str], Unused] = ...) -> None: ...
def UninstallModule(conf_module_name: StrPath, params, options, log: Callable[[int, str], Unused] = ...) -> None: ...
def InstallModule(conf_module_name: StrPath, params, options, log: Callable[[int, object], Unused] = ...) -> None: ...
def UninstallModule(conf_module_name: StrPath, params, options, log: Callable[[int, object], Unused] = ...) -> None: ...

Copy link
Collaborator
@Avasam Avasam Apr 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Yeah.

Copy link
Collaborator
@Avasam Avasam Apr 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donBarbos My bad. I answered too fast. Here it means "this function expects to be passed a log parameter that should be a function that accepts a str as the 2nd parameter".

In other words, we want to ensure that whatever function will be passed here will work once a string is passed. The typing here is based on usage, it's completely separate from isapi.isntall.log

I went ahead and reverted the last commit.


standard_arguments: Incomplete
standard_arguments: Final[dict[Literal["install", "remove"], Callable[..., Incomplete]]]

def build_usage(handler_map): ...
def build_usage(handler_map: Mapping[str, object]) -> str: ...
def MergeStandardOptions(options, params) -> None: ...
def HandleCommandLine(
params,
argv: Incomplete | None = None,
conf_module_name: Incomplete | None = None,
argv: SupportsGetItem[int, str] | None = None,
conf_module_name: str | None = None,
default_arg: str = "install",
opt_parser: Incomplete | None = None,
custom_arg_handlers={},
opt_parser: OptionParser | None = None,
custom_arg_handlers: Mapping[str, object] = {},
) -> None: ...
170 changes: 85 additions & 85 deletions stubs/pywin32/isapi/isapicon.pyi
F438
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
from _typeshed import Incomplete
from typing import Final

HTTP_CONTINUE: int
HTTP_SWITCHING_PROTOCOLS: int
HTTP_PROCESSING: int
HTTP_OK: int
HTTP_CREATED: int
HTTP_ACCEPTED: int
HTTP_NON_AUTHORITATIVE: int
HTTP_NO_CONTENT: int
HTTP_RESET_CONTENT: int
HTTP_PARTIAL_CONTENT: int
HTTP_MULTI_STATUS: int
HTTP_MULTIPLE_CHOICES: int
HTTP_MOVED_PERMANENTLY: int
HTTP_MOVED_TEMPORARILY: int
HTTP_SEE_OTHER: int
HTTP_NOT_MODIFIED: int
HT ED4F TP_USE_PROXY: int
HTTP_TEMPORARY_REDIRECT: int
HTTP_BAD_REQUEST: int
HTTP_UNAUTHORIZED: int
HTTP_PAYMENT_REQUIRED: int
HTTP_FORBIDDEN: int
HTTP_NOT_FOUND: int
HTTP_METHOD_NOT_ALLOWED: int
HTTP_NOT_ACCEPTABLE: int
HTTP_PROXY_AUTHENTICATION_REQUIRED: int
HTTP_REQUEST_TIME_OUT: int
HTTP_CONFLICT: int
HTTP_GONE: int
HTTP_LENGTH_REQUIRED: int
HTTP_PRECONDITION_FAILED: int
HTTP_REQUEST_ENTITY_TOO_LARGE: int
HTTP_REQUEST_URI_TOO_LARGE: int
HTTP_UNSUPPORTED_MEDIA_TYPE: int
HTTP_RANGE_NOT_SATISFIABLE: int
HTTP_EXPECTATION_FAILED: int
HTTP_UNPROCESSABLE_ENTITY: int
HTTP_INTERNAL_SERVER_ERROR: int
HTTP_NOT_IMPLEMENTED: int
HTTP_BAD_GATEWAY: int
HTTP_SERVICE_UNAVAILABLE: int
HTTP_GATEWAY_TIME_OUT: int
HTTP_VERSION_NOT_SUPPORTED: int
HTTP_VARIANT_ALSO_VARIES: int
HSE_STATUS_SUCCESS: int
HSE_STATUS_SUCCESS_AND_KEEP_CONN: int
HSE_STATUS_PENDING: int
HSE_STATUS_ERROR: int
SF_NOTIFY_SECURE_PORT: int
SF_NOTIFY_NONSECURE_PORT: int
SF_NOTIFY_READ_RAW_DATA: int
SF_NOTIFY_PREPROC_HEADERS: int
SF_NOTIFY_AUTHENTICATION: int
SF_NOTIFY_URL_MAP: int
SF_NOTIFY_ACCESS_DENIED: int
SF_NOTIFY_SEND_RESPONSE: int
SF_NOTIFY_SEND_RAW_DATA: int
SF_NOTIFY_LOG: int
SF_NOTIFY_END_OF_REQUEST: int
SF_NOTIFY_END_OF_NET_SESSION: int
SF_NOTIFY_ORDER_HIGH: int
SF_NOTIFY_ORDER_MEDIUM: int
SF_NOTIFY_ORDER_LOW: int
SF_NOTIFY_ORDER_DEFAULT: int
SF_NOTIFY_ORDER_MASK: Incomplete
SF_STATUS_REQ_FINISHED: int
SF_STATUS_REQ_FINISHED_KEEP_CONN: Incomplete
SF_STATUS_REQ_NEXT_NOTIFICATION: Incomplete
SF_STATUS_REQ_HANDLED_NOTIFICATION: Incomplete
SF_STATUS_REQ_ERROR: Incomplete
SF_STATUS_REQ_READ_NEXT: Incomplete
HSE_IO_SYNC: int
HSE_IO_ASYNC: int
HSE_IO_DISCONNECT_AFTER_SEND: int
HSE_IO_SEND_HEADERS: int
HSE_IO_NODELAY: int
HSE_IO_FINAL_SEND: int
HSE_IO_CACHE_RESPONSE: int
HSE_EXEC_URL_NO_HEADERS: int
HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR: int
HSE_EXEC_URL_IGNORE_VALIDATION_AND_RANGE: int
HSE_EXEC_URL_DISABLE_CUSTOM_ERROR: int
HSE_EXEC_URL_SSI_CMD: int
HSE_EXEC_URL_HTTP_CACHE_ELIGIBLE: int
HTTP_CONTINUE: Final = 100
HTTP_SWITCHING_PROTOCOLS: Final = 101
HTTP_PROCESSING: Final = 102
HTTP_OK: Final = 200
HTTP_CREATED: Final = 201
HTTP_ACCEPTED: Final = 202
HTTP_NON_AUTHORITATIVE: Final = 203
HTTP_NO_CONTENT: Final = 204
HTTP_RESET_CONTENT: Final = 205
HTTP_PARTIAL_CONTENT: Final = 206
HTTP_MULTI_STATUS: Final = 207
HTTP_MULTIPLE_CHOICES: Final = 300
HTTP_MOVED_PERMANENTLY: Final = 301
HTTP_MOVED_TEMPORARILY: Final = 302
HTTP_SEE_OTHER: Final = 303
HTTP_NOT_MODIFIED: Final = 304
HTTP_USE_PROXY: Final = 305
HTTP_TEMPORARY_REDIRECT: Final = 307
HTTP_BAD_REQUEST: Final = 400
HTTP_UNAUTHORIZED: Final = 401
HTTP_PAYMENT_REQUIRED: Final = 402
HTTP_FORBIDDEN: Final = 403
HTTP_NOT_FOUND: Final = 404
HTTP_METHOD_NOT_ALLOWED: Final = 405
HTTP_NOT_ACCEPTABLE: Final = 406
HTTP_PROXY_AUTHENTICATION_REQUIRED: Final = 407
HTTP_REQUEST_TIME_OUT: Final = 408
HTTP_CONFLICT: Final = 409
HTTP_GONE: Final = 410
HTTP_LENGTH_REQUIRED: Final = 411
HTTP_PRECONDITION_FAILED: Final = 412
HTTP_REQUEST_ENTITY_TOO_LARGE: Final = 413
HTTP_REQUEST_URI_TOO_LARGE: Final = 414
HTTP_UNSUPPORTED_MEDIA_TYPE: Final = 415
HTTP_RANGE_NOT_SATISFIABLE: Final = 416
HTTP_ 1E79 EXPECTATION_FAILED: Final = 417
HTTP_UNPROCESSABLE_ENTITY: Final = 422
HTTP_INTERNAL_SERVER_ERROR: Final = 500
HTTP_NOT_IMPLEMENTED: Final = 501
HTTP_BAD_GATEWAY: Final = 502
HTTP_SERVICE_UNAVAILABLE: Final = 503
HTTP_GATEWAY_TIME_OUT: Final = 504
HTTP_VERSION_NOT_SUPPORTED: Final = 505
HTTP_VARIANT_ALSO_VARIES: Final = 506
HSE_STATUS_SUCCESS: Final = 1
HSE_STATUS_SUCCESS_AND_KEEP_CONN: Final = 2
HSE_STATUS_PENDING: Final = 3
HSE_STATUS_ERROR: Final = 4
SF_NOTIFY_SECURE_PORT: Final = 0x00000001
SF_NOTIFY_NONSECURE_PORT: Final = 0x00000002
SF_NOTIFY_READ_RAW_DATA: Final = 0x00008000
SF_NOTIFY_PREPROC_HEADERS: Final = 0x00004000
SF_NOTIFY_AUTHENTICATION: Final = 0x00002000
SF_NOTIFY_URL_MAP: Final = 0x00001000
SF_NOTIFY_ACCESS_DENIED: Final = 0x00000800
SF_NOTIFY_SEND_RESPONSE: Final = 0x00000040
SF_NOTIFY_SEND_RAW_DATA: Final = 0x00000400
SF_NOTIFY_LOG: Final = 0x00000200
SF_NOTIFY_END_OF_REQUEST: Final = 0x00000080
SF_NOTIFY_END_OF_NET_SESSION: Final = 0x00000100
SF_NOTIFY_ORDER_HIGH: Final = 0x00080000
SF_NOTIFY_ORDER_MEDIUM: Final = 0x00040000
SF_NOTIFY_ORDER_LOW: Final = 0x00020000
SF_NOTIFY_ORDER_DEFAULT: Final = SF_NOTIFY_ORDER_LOW
SF_NOTIFY_ORDER_MASK: Final = 917504
SF_STATUS_REQ_FINISHED: Final = 134217728
SF_STATUS_REQ_FINISHED_KEEP_CONN: Final = 134217729
SF_STATUS_REQ_NEXT_NOTIFICATION: Final = 134217730
SF_STATUS_REQ_HANDLED_NOTIFICATION: Final = 134217731
SF_STATUS_REQ_ERROR: Final = 134217732
SF_STATUS_REQ_READ_NEXT: Final = 134217733
HSE_IO_SYNC: Final = 0x00000001
HSE_IO_ASYNC: Final = 0x00000002
HSE_IO_DISCONNECT_AFTER_SEND: Final = 0x00000004
HSE_IO_SEND_HEADERS: Final = 0x00000008
HSE_IO_NODELAY: Final = 0x00001000
HSE_IO_FINAL_SEND: Final = 0x00000010
HSE_IO_CACHE_RESPONSE: Final = 0x00000020
HSE_EXEC_URL_NO_HEADERS: Final = 0x02
HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR: Final = 0x04
HSE_EXEC_URL_IGNORE_VALIDATION_AND_RANGE: Final = 0x10
HSE_EXEC_URL_DISABLE_CUSTOM_ERROR: Final = 0x20
HSE_EXEC_URL_SSI_CMD: Final = 0x40
HSE_EXEC_URL_HTTP_CACHE_ELIGIBLE: Final = 0x80
2 changes: 1 addition & 1 deletion stubs/pywin32/isapi/simple.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class SimpleExtension:
def GetExtensionVersion(self, vi) -> None: ...
def HttpExtensionProc(self, control_block) -> None: ...
def HttpExtensionProc(self, control_block) -> int | None: ...
def TerminateExtension(self, status) -> None: ...

class SimpleFilter:
Expand Down
22 changes: 12 additions & 10 deletions stubs/pywin32/isapi/threaded_extension.pyi
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import threading
from _typeshed import Incomplete
from _typeshed import Unused
from collections.abc import Callable
from typing import Final

import isapi.simple

ISAPI_REQUEST: int
ISAPI_SHUTDOWN: int
ISAPI_REQUEST: Final = 1
ISAPI_SHUTDOWN: Final = 2

class WorkerThread(threading.Thread):
running: bool
io_req_port: Incomplete
extension: Incomplete
def __init__(self, extension, io_req_port) -> None: ...
io_req_port: int
extension: ThreadPoolExtension
def __init__(self, extension: ThreadPoolExtension, io_req_port: int) -> None: ...
def call_handler(self, cblock) -> None: ...

class ThreadPoolExtension(isapi.simple.SimpleExtension):
max_workers: int
worker_shutdown_wait: int
workers: Incomplete
dispatch_map: Incomplete
io_req_port: Incomplete
workers: list[WorkerThread]
dispatch_map: dict[int, Callable[..., Unused]]
io_req_port: int
def GetExtensionVersion(self, vi) -> None: ...
def HttpExtensionProc(self, control_block): ...
def HttpExtensionProc(self, control_block) -> int: ...
def TerminateExtension(self, status) -> None: ...
def DispatchConnection(self, errCode, bytes, key, overlapped) -> None: ...
def Dispatch(self, ecb) -> None: ...
Expand Down
0