Skip to content

Commit b8b200c

Browse files
authored
Merge pull request ahupp#220 from coiax/stub
🐑 Create basic stub file for magic.py
2 parents 217c91b + f645c39 commit b8b200c

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

magic.pyi

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import ctypes.util
2+
import threading
3+
from typing import Any, Text, Optional, Union
4+
5+
class MagicException(Exception):
6+
message: Any = ...
7+
def __init__(self, message: Any) -> None: ...
8+
9+
class Magic:
10+
flags: int = ...
11+
cookie: Any = ...
12+
lock: threading.Lock = ...
13+
def __init__(self, mime: bool = ..., magic_file: Optional[Any] = ..., mime_encoding: bool = ..., keep_going: bool = ..., uncompress: bool = ..., raw: bool = ...) -> None: ...
14+
def from_buffer(self, buf: Union[bytes, str]) -> Text: ...
15+
def from_file(self, filename: Union[bytes, str]) -> Text: ...
16+
def setparam(self, param: Any, val: Any): ...
17+
def getparam(self, param: Any): ...
18+
def __del__(self) -> None: ...
19+
20+
def from_file(filename: Union[bytes, str], mime: bool = ...) -> Text: ...
21+
def from_buffer(buffer: Union[bytes, str], mime: bool = ...) -> Text: ...
22+
23+
libmagic: Any
24+
dll: Any
25+
windows_dlls: Any
26+
platform_to_lib: Any
27+
platform: Any
28+
magic_t = ctypes.c_void_p
29+
30+
def errorcheck_null(result: Any, func: Any, args: Any): ...
31+
def errorcheck_negative_one(result: Any, func: Any, args: Any): ...
32+
def maybe_decode(s: Union[bytes, str]) -> str: ...
33+
def coerce_filename(filename: Any): ...
34+
35+
magic_open: Any
36+
magic_close: Any
37+
magic_error: Any
38+
magic_errno: Any
39+
40+
def magic_file(cookie: Any, filename: Any): ...
41+
def magic_buffer(cookie: Any, buf: Any): ...
42+
def magic_load(cookie: Any, filename: Any): ...
43+
44+
magic_setflags: Any
45+
magic_check: Any
46+
magic_compile: Any
47+
48+
def magic_setparam(cookie: Any, param: Any, val: Any): ...
49+
def magic_getparam(cookie: Any, param: Any): ...
50+
51+
magic_version: Any
52+
53+
def version(): ...
54+
55+
MAGIC_NONE: int
56+
MAGIC_DEBUG: int
57+
MAGIC_SYMLINK: int
58+
MAGIC_COMPRESS: int
59+
MAGIC_DEVICES: int
60+
MAGIC_MIME_TYPE: int
61+
MAGIC_MIME_ENCODING: int
62+
MAGIC_MIME: int
63+
MAGIC_CONTINUE: int
64+
MAGIC_CHECK: int
65+
MAGIC_PRESERVE_ATIME: int
66+
MAGIC_RAW: int
67+
MAGIC_ERROR: int
68+
MAGIC_NO_CHECK_COMPRESS: int
69+
MAGIC_NO_CHECK_TAR: int
70+
MAGIC_NO_CHECK_SOFT: int
71+
MAGIC_NO_CHECK_APPTYPE: int
72+
MAGIC_NO_CHECK_ELF: int
73+
MAGIC_NO_CHECK_ASCII: int
74+
MAGIC_NO_CHECK_TROFF: int
75+
MAGIC_NO_CHECK_FORTRAN: int
76+
MAGIC_NO_CHECK_TOKENS: int
77+
MAGIC_PARAM_INDIR_MAX: int
78+
MAGIC_PARAM_NAME_MAX: int
79+
MAGIC_PARAM_ELF_PHNUM_MAX: int
80+
MAGIC_PARAM_ELF_SHNUM_MAX: int
81+
MAGIC_PARAM_ELF_NOTES_MAX: int
82+
MAGIC_PARAM_REGEX_MAX: int
83+
MAGIC_PARAM_BYTES_MAX: int

tox.ini

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ envlist =
66
py36,
77
py37,
88
py38,
9-
coverage-report
9+
coverage-report,
10+
mypy
1011

1112
[testenv]
1213
commands =
@@ -37,3 +38,9 @@ commands =
3738
coverage report
3839
coverage html
3940
coverage
41+
42+
[testenv:mypy]
43+
deps = mypy
44+
skip_install = true
45+
commands =
46+
mypy magic.pyi

0 commit comments

Comments
 (0)