Utility functions with no non-trivial dependencies.
Class |
|
Apply color and bold font to terminal output. |
Class |
|
Generate integer ids for objects. |
Exception |
|
Exception raised when a file cannot be decoded due to an unknown encoding type. |
Function | bytes |
Converts bytes into some human-readable representation. Unprintable bytes such as the nul byte are escaped. For example: |
Function | check |
Report issues with the Python used to run mypy, dmypy, or stubgen |
Function | correct |
Undocumented |
Function | count |
Count total number of errors, notes and error_files in message list. |
Function | decode |
Read the Python file with while obeying PEP-263 encoding detection. |
Function | find |
PEP-263 for detecting Python file encoding |
Function | get |
Undocumented |
Function | get |
Undocumented |
Function | get |
Drop the final component of a qualified name (e.g. ('x.y' -> 'x'). |
Function | get |
Get current terminal width if possible, otherwise return the default one. |
Function | get |
Return one and two component prefixes of a fully qualified name. |
Function | get |
Get a simple redefinition name not present among existing. |
Function | hard |
Kill the current process without fully cleaning up. |
Function | hash |
Compute a hash digest of some data. |
Function | is |
Returns whether name is a dunder name. |
Function | is |
Undocumented |
Function | is |
Given two paths, return if path1 is a sub-path of path2. |
Function | is |
Undocumented |
Function | is |
Undocumented |
Function | module |
Undocumented |
Function | parse |
Reproduce a gray color in ANSI escape sequence |
Function | plural |
Undocumented |
Function | read |
Try reading a Python file as list of source lines. |
Function | replace |
Copy state of old node to the new node. |
Function | short |
Return the last component of the type name of an object. |
Function | should |
Undocumented |
Function | soft |
Wrap a long error message into few lines. |
Function | split |
Return the module and all parent module names. |
Function | split |
Undocumented |
Function | split |
Split line of text into words (but not within quoted groups). |
Function | time |
Undocumented |
Function | trim |
Trim a line of source code to fit into max_len. |
Function | unmangle |
Remove internal suffixes from a short name. |
Function | unnamed |
Undocumented |
Function | write |
Undocumented |
Constant | CURSES |
Undocumented |
Constant | DEFAULT |
Undocumented |
Constant | DEFAULT |
Undocumented |
Constant | ENCODING |
Undocumented |
Constant | ERROR |
Undocumented |
Constant | FAIL |
Undocumented |
Constant | fields |
Undocumented |
Constant | MINIMUM |
Undocumented |
Constant | MINIMUM |
Undocumented |
Constant | MINIMUM |
Undocumented |
Constant | PASS |
Undocumented |
Constant | SPECIAL |
Undocumented |
Constant | TYPESHED |
Undocumented |
Type Variable | T |
Undocumented |
Converts bytes into some human-readable representation. Unprintable bytes such as the nul byte are escaped. For example: >>> b = bytes([102, 111, 111, 10, 0]) >>> s = bytes_to_human_readable_repr(b) >>> print(s) foo >>> print(repr(s)) 'foo\n\x00'
str
, relative: int
, target: str
, is_cur_package_init_file: bool
) -> tuple[ str, bool]
:
(source)
¶
Undocumented
Return one and two component prefixes of a fully qualified name. Given 'a.b.c.d', return ('a', 'a.b'). If fullname has only one component, return (fullname, fullname).
Get a simple redefinition name not present among existing. For example, for name 'foo' we try 'foo-redefinition', 'foo-redefinition2', 'foo-redefinition3', etc. until we find one that is not in existing.
Kill the current process without fully cleaning up. This can be quite a bit faster than a normal exit() since objects are not freed.
Compute a hash digest of some data. We use a cryptographic hash because we want a low probability of accidental collision, but we don't really care about any of the cryptographic properties.
Returns whether name is a dunder name. Args: exclude_special: Whether to return False for a couple special dunder methods.
object
, old: object
, copy_dict: bool
= False, skip_slots: tuple[ str, ...]
= ()):
(source)
¶
Copy state of old node to the new node. This handles cases where there is __dict__ and/or attribute descriptors (either from slots or because the type is defined in a C extension module). Assume that both objects have the same __class__.
Return the last component of the type name of an object. If obj is None, return 'nil'. For example, if obj is 1, return 'int'.
Wrap a long error message into few lines. Breaks will only happen between words, and never inside a quoted group (to avoid breaking types such as "Union[int, str]"). The 'first_offset' is the width before the start of first line. Pad every next line with 'num_indent' spaces. Every line will be at most 'max_len' characters, except if it is a single word or quoted group. For example: first_offset ------------------------ path/to/file: error: 58: Some very long error message that needs to be split in separate lines. "Long[Type, Names]" are never split. ^^^^-------------------------------------------------- num_indent max_len
Return the module and all parent module names. So, if `mod_name` is 'a.b.c', this function will return ['a.b.c', 'a.b', and 'a'].
str
, max_len: int
, col: int
, min_width: int
) -> tuple[ str, int]
:
(source)
¶
Trim a line of source code to fit into max_len. Show 'min_width' characters on each side of 'col' (an error location). If either start or end is trimmed, this is indicated by adding '...' there. A typical result looks like this: ...some_variable = function_to_call(one_arg, other_arg) or... Return the trimmed string and the column offset to to adjust error location.
float
, serious: bool
, messages: list[ str]
, path: str
, version: str
, platform: str
):
(source)
¶
Undocumented
Undocumented
Value |
|
Undocumented
Value |
|
Undocumented
Value |
|
Undocumented
Value |
|