stubber.rst
¶
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¶
- stubber.rst.sort_classes(classes: List[str])¶
sort a list of classes to respect the parent-child order
- Parameters
classes (List[str]) –
- 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 = [['\\*', '*'], ['\\**', '*'], ['/*', '*'], ["'param'", 'param'], ['lambda', 'lambda_fn'],...¶
- stubber.rst.MODULE_GLUE¶
- stubber.rst.RST_DOC_FIXES = [['.. method:: match.', '.. method:: Match.'], [' match.end', ' ...¶
- stubber.rst.DOCSTUB_SKIP = ['uasyncio.rst', 'builtins.rst', 're.rst']¶
- stubber.rst.U_MODULES = ['os', 'time', 'array', 'binascii', 'io', 'json', 'select', 'socket', 'ssl', 'struct', 'zlib']¶
- class stubber.rst.SourceDict(base: List, indent: int = 0, body: int = 0, lf: str = '\n')¶
Bases:
OrderedDict
(abstract) dict to store source components respecting parent child dependencies and proper definition order
- __add__(dict: SourceDict)¶
- Parameters
dict (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__()¶
convert the OD into a string
- find(name: str) Union[str, None] ¶
find a classnode based on the name with or without the superclass
- classes()¶
get a list of the class names in parent-child order
- class stubber.rst.ClassSourceDict(name: str, *, docstr: List[str] = ['""" """'], 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] = [], docstr: List[str] = ['""" """'], indent: int = 0, decorators: List[str] = [], lf='\n')¶
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] = [])¶
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] = [])¶
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] = ['IRQ'])¶
find and rate possible types and confidence weighting for Object types. Case sensitive
- 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: Union[str, List[str]], signature: str, module: str, literal: bool = False)¶
- stubber.rst._type_from_context(*, docstring: Union[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 typing import IO, Any, Callable, Coroutine, Dict, Generator, Iterator, List, NoReturn,...¶
- stubber.rst.__all__¶