stubber.rst
¶
.rst processing
Submodules¶
Package Contents¶
Classes¶
(abstract) dict to store source components respecting parent child dependencies and proper definition order |
|
(abstract) dict to store source components respecting parent child dependencies and proper definition order |
|
(abstract) dict to store source components respecting parent child dependencies and proper definition order |
|
(abstract) dict to store source components respecting parent child dependencies and proper definition order |
Functions¶
|
sort a list of classes to respect the parent-child order |
|
find and rate possible types and confidence weighting for simple types. |
|
find and rate possible types and confidence weighting for compound types that can have a subscription. |
|
find and rate possible types and confidence weighting for Object types. |
|
Find return type and confidence. |
|
|
|
Determine the return type of a function or method based on: |
Attributes¶
this is an list with manual overrides for function returns that could not efficiently be determined |
|
List of modules that are documented with the base name only, |
|
- stubber.rst.sort_classes(classes: List[str])¶
sort a list of classes to respect the parent-child order
- Parameters:
classes (List[str]) –
- stubber.rst.TYPING_IMPORT: List[str] = ['from __future__ import annotations', 'from typing import IO, Any, Callable, Coroutine, Dict,...¶
- stubber.rst.LOOKUP_LIST¶
- stubber.rst.NONE_VERBS = ['Activate ', 'Build a ', 'Cancel ', 'Clear ', 'Close ', 'cancel ', 'Configure ', 'Connect ',...¶
- stubber.rst.CHILD_PARENT_CLASS¶
- stubber.rst.PARAM_FIXES¶
- stubber.rst.MODULE_GLUE¶
- stubber.rst.RST_DOC_FIXES: List[Tuple[str, str]] = [(':class: attention\n', ''), ('.. method:: match.', '.. method:: Match.'), (' ...¶
- stubber.rst.DOCSTUB_SKIP = ['uasyncio.rst', 'builtins.rst', 're.rst']¶
this is an list with manual overrides for function returns that could not efficiently be determined from their docstring description Format: a dictionary with : - key = module.[class.]function name - value : two-tuple with ( return type , priority )
- stubber.rst.U_MODULES = ['array', 'binascii', 'io', 'json', 'os', 'select', 'ssl', 'struct', 'socket', 'time', 'zlib']¶
List of modules that are documented with the base name only, but can also be imported with a u prefix
- class stubber.rst.SourceDict(base: List, indent: int = 0, body: int = 0, lf: str = '\n', name='')¶
Bases:
OrderedDict
(abstract) dict to store source components respecting parent child dependencies and proper definition order
- __add__(other: SourceDict)¶
Aallows instances of the SourceDict class to be added together using the + operator or the += operator.
- Parameters:
other (SourceDict) –
- class stubber.rst.ModuleSourceDict(name: str, indent=0, lf: str = '\n')¶
Bases:
SourceDict
(abstract) dict to store source components respecting parent child dependencies and proper definition order
- sort()¶
make sure all classdefs are in order
- __str__()¶
sort in the correct parent-child order, then convert to string (the code)
- classes()¶
get a list of the class names in parent-child order
- class stubber.rst.ClassSourceDict(name: str, *, docstr: List[str] | None = None, init: str = '', indent: int = 0, lf='\n')¶
Bases:
SourceDict
(abstract) dict to store source components respecting parent child dependencies and proper definition order
- class stubber.rst.FunctionSourceDict(name: str, *, definition: List[str] | None = None, docstr: List[str] | None = None, indent: int = 0, decorators: List[str] | None = None, lf='\n', is_async: bool = False)¶
Bases:
SourceDict
(abstract) dict to store source components respecting parent child dependencies and proper definition order
- stubber.rst.simple_candidates(type: str, match_string: str, keywords: List[str], rate: float = 0.5, exclude: List[str] | None = None)¶
find and rate possible types and confidence weighting for simple types. Case sensitive
- stubber.rst.compound_candidates(type: str, match_string: str, keywords: List[str], rate: float = 0.85, exclude: List[str] | None = None)¶
find and rate possible types and confidence weighting for compound types that can have a subscription. Case sensitive
- stubber.rst.object_candidates(match_string: str, rate: float = 0.81, exclude: List[str] | None = None)¶
find and rate possible types and confidence weighting for Object types. Case sensitive Exclude defaults to [“IRQ”]
- stubber.rst.distill_return(return_text: str) List[Dict] ¶
Find return type and confidence. Returns a list of possible types and confidence weighting. {
type :str # the return type confidence: float # the confidence between 0.0 and 1 match: Optional[str] # for debugging : the reason the match was made
}
- Parameters:
return_text (str) –
- Return type:
List[Dict]
- stubber.rst.return_type_from_context(*, docstring: str | List[str], signature: str, module: str, literal: bool = False)¶
- stubber.rst._type_from_context(*, docstring: str | List[str], signature: str, module: str, literal: bool = False)¶
- Determine the return type of a function or method based on:
the function signature
the terminology used in the docstring
Logic: - if the signature contains a return type –> <something> then that is returned - use re to find phrases such as:
‘Returns ….. ‘
‘Gets ….. ‘
docstring is joined without newlines to simplify parsing
then parses the docstring to find references to known types and give then a rating though a hand coded model ()
builds a list return type candidates
selects the highest ranking candidate
the default Type is ‘Any’
- stubber.rst.TYPING_IMPORT: List[str] = ['from __future__ import annotations', 'from typing import IO, Any, Callable, Coroutine, Dict,...¶
- stubber.rst.__all__¶