Skip to content

Add stubs for show-in-file-manager #9313

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"stubs/redis",
"stubs/requests",
"stubs/setuptools",
"stubs/show-in-file-manager",
"stubs/SQLAlchemy",
"stubs/stripe",
"stubs/tqdm",
Expand Down
6 changes: 6 additions & 0 deletions stubs/show-in-file-manager/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
showinfm.system.tools.cannot_open_uris
showinfm.showinfm.is_wsl
showinfm.showinfm.is_wsl1
showinfm.showinfm.is_wsl2
showinfm.showinfm.single_file_only
showinfm.showinfm.cannot_open_uris
4 changes: 4 additions & 0 deletions stubs/show-in-file-manager/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version = "1.1.*"

[tool.stubtest]
ignore_missing_stub = false
12 changes: 12 additions & 0 deletions stubs/show-in-file-manager/showinfm/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from showinfm.constants import cannot_open_uris as cannot_open_uris, single_file_only as single_file_only
from showinfm.showinfm import (
show_in_file_manager as show_in_file_manager,
stock_file_manager as stock_file_manager,
user_file_manager as user_file_manager,
valid_file_manager as valid_file_manager,
)
from showinfm.system.linux import (
LinuxDesktop as LinuxDesktop,
linux_desktop as linux_desktop,
linux_desktop_humanize as linux_desktop_humanize,
)
20 changes: 20 additions & 0 deletions stubs/show-in-file-manager/showinfm/constants.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from _typeshed import Incomplete
from enum import Enum

class FileManagerType(Enum):
regular: int
select: int
dir_only_uri: int
show_item: int
show_items: int
win_select: int
reveal: int
dual_panel: int

class Platform(Enum):
windows: int
linux: int
macos: int

single_file_only: Incomplete
cannot_open_uris: Incomplete
26 changes: 26 additions & 0 deletions stubs/show-in-file-manager/showinfm/showinfm.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import argparse
import typing as t

def stock_file_manager() -> str: ...
def user_file_manager() -> str: ...
def valid_file_manager() -> str: ...
def show_in_file_manager(
path_or_uri: str | t.Sequence[str] | None = ...,
open_not_select_directory: bool | None = ...,
file_manager: str | None = ...,
allow_conversion: bool = ...,
verbose: bool = ...,
debug: bool = ...,
) -> None: ...

class Diagnostics:
stock_file_manager: str
user_file_manager: str
valid_file_manager: str
desktop: str
wsl_version: str
def __init__(self) -> None: ...

def package_metadata() -> tuple[str, str]: ...
def parser_options(formatter_class: t.Type[argparse.HelpFormatter] = ...) -> argparse.HelpFormatter: ...
def main() -> None: ...
7 changes: 7 additions & 0 deletions stubs/show-in-file-manager/showinfm/system/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ..constants import Platform

system: str
is_wsl: bool
is_wsl1: bool
is_wsl2: bool
current_platform: Platform
61 changes: 61 additions & 0 deletions stubs/show-in-file-manager/showinfm/system/linux.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import typing as t
from _typeshed import Incomplete
from enum import Enum

from ..constants import FileManagerType

# must be replaced by packaging.version.Version after implementing of https://github.com/python/typeshed/issues/5768
_packaging_Version = Incomplete

def stock_linux_file_manager() -> str: ...
def user_linux_file_manager() -> str: ...
def valid_linux_file_manager() -> str: ...
def known_linux_file_managers() -> tuple[str]: ...
def linux_file_manager_type(file_manager: str) -> FileManagerType: ...
def caja_version() -> _packaging_Version | None: ...
def caja_supports_select() -> bool: ...
def translate_wsl_path(path: str, from_windows_to_wsl: bool) -> str: ...
def wsl_path_is_for_windows(path_or_uri: str) -> bool: ...

class WSLTransformPathURI(t.NamedTuple):
is_win_location: bool
win_uri: str
win_path: str
linux_path: str
is_dir: bool
exists: bool

def wsl_transform_path_uri(path_or_uri: str, generate_win_path: bool) -> WSLTransformPathURI: ...
def wsl_path_to_uri_for_windows_explorer(path: str) -> str: ...

class LinuxDesktop(Enum):
gnome: int
unity: int
cinnamon: int
kde: int
xfce: int
mate: int
lxde: int
lxqt: int
ubuntugnome: int
popgnome: int
deepin: int
zorin: int
ukui: int
pantheon: int
enlightenment: int
wsl: int
wsl2: int
cutefish: int
lumina: int
unknown: int

LinuxDesktopHumanize: dict[str, str]
LinuxDesktopFamily: dict[str, str]
StandardLinuxFileManager: dict[str, str]
LinuxFileManagerBehavior: dict[str, FileManagerType]

def wsl_version() -> LinuxDesktop | None: ...
def detect_wsl() -> bool: ...
def linux_desktop() -> LinuxDesktop: ...
def linux_desktop_humanize(desktop: LinuxDesktop) -> str: ...
11 changes: 11 additions & 0 deletions stubs/show-in-file-manager/showinfm/system/tools.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from collections import defaultdict
from pathlib import Path

from . import is_wsl2 as is_wsl2

def filemanager_requires_path(file_manager: str) -> bool: ...
def is_uri(path_uri: str) -> bool: ...
def quote_path(path: Path) -> Path: ...
def path_to_file_uri(path: str) -> str: ...
def file_uri_to_path(uri: str) -> str: ...
def directories_and_their_files(paths: list[str]) -> defaultdict[str, list[str]]: ...
92 changes: 92 additions & 0 deletions stubs/show-in-file-manager/showinfm/system/urivalidate.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
__license__: str
DIGIT: str
ALPHA: str
HEXDIG: str
DQUOTE: str
pct_encoded: str
unreserved: str
gen_delims: str
sub_delims: str
pchar: str
reserved: str
scheme: str
dec_octet: str
IPv4address: str
h16: str
ls32: str
IPv6address: str
IPvFuture: str
IP_literal: str
reg_name: str
userinfo: str
host: str
port: str
authority: str
segment: str
segment_nz: str
segment_nz_nc: str
path_abempty: str
path_absolute: str
path_noscheme: str
path_rootless: str
path_empty: str
path: str
query: str
fragment: str
hier_part: str
relative_part: str
relative_ref: str
URI: str
URI_reference: str
absolute_URI: str
http_URI: str
https_URI: str
ws_URI: str
wss_URI: str
some_delims: str
qchar: str
dtext_no_obs: str
rfc5322_atext: str
rfc5322_dot_atom_text: str
qcontent: str
rfc5322_FWS: str
rfc5322_CFWS: str
rfc5322_quoted_string: str
domain: str
local_part: str
addr_spec: str
hfvalue: str
hfname: str
hfield: str
to: str
hfields: str
mailto_URI: str
rfc2045_token: str
rfc2045_ietf_token: str
rfc2045_iana_tokens: str
rfc2045_x_token: str
rfc2045_extension_token: str
rfc2045_discrete_type: str
rfc2045_composite_type: str
rfc2045_type: str
rfc2045_subtype: str
rfc2045_quoted_string: str
rfc2045_attribute: str
rfc2045_value: str
rfc2045_parameter: str
mediatype: str
rfc2396_uric: str
data: str
data_URI: str
gopher_path: str
gopher_URI: str
file_f_scheme: str
file_f_auth: str
file_unc_path: str
file_drive_marker: str
file_drive_letter: str
file_windows_path: str
file_local_path: str
file_auth_path: str
file_f_hier_part: str
file_URI: str
7 changes: 7 additions & 0 deletions stubs/show-in-file-manager/showinfm/system/windows.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ..constants import FileManagerType

WindowsFileManagerBehavior: dict[str, FileManagerType]

def windows_file_manager_type(file_manager: str) -> FileManagerType: ...
def parse_command_line_arguments(path_or_uri: list[str]) -> list[str]: ...
def launch_file_explorer(paths: list[str], verbose: bool | None = ...) -> None: ...