' + + '' + + _("Hide Search Matches") + + "
" + ) + ); + }, + + /** + * helper function to hide the search marks again + */ + hideSearchWords: () => { + document + .querySelectorAll("#searchbox .highlight-link") + .forEach((el) => el.remove()); + document + .querySelectorAll("span.highlighted") + .forEach((el) => el.classList.remove("highlighted")); + localStorage.removeItem("sphinx_highlight_terms") + }, + + initEscapeListener: () => { + // only install a listener if it is really needed + if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return; + + document.addEventListener("keydown", (event) => { + // bail for input elements + if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return; + // bail with special keys + if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return; + if (DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS && (event.key === "Escape")) { + SphinxHighlight.hideSearchWords(); + event.preventDefault(); + } + }); + }, +}; + +_ready(SphinxHighlight.highlightSearchWords); +_ready(SphinxHighlight.initEscapeListener); diff --git a/docs/build/html/_static/theme_extras.js b/docs/build/html/_static/theme_extras.js new file mode 100644 index 0000000..df2be40 --- /dev/null +++ b/docs/build/html/_static/theme_extras.js @@ -0,0 +1,12 @@ +const initialiseThemeExtras = () => { + const toc = document.getElementById("toc") + toc.style.display = "" + const items = toc.getElementsByTagName("ul")[0] + items.style.display = "none" + toc.getElementsByTagName("h3").addEventListener("click", () => { + if (items.style.display !== "none") toc.classList.remove("expandedtoc") + else toc.classList.add("expandedtoc"); + }) +} +if (document.readyState !== "loading") initialiseThemeExtras() +else document.addEventListener("DOMContentLoaded", initialiseThemeExtras) diff --git a/docs/build/html/_static/transparent.gif b/docs/build/html/_static/transparent.gif new file mode 100644 index 0000000..0341802 Binary files /dev/null and b/docs/build/html/_static/transparent.gif differ diff --git a/docs/build/html/_static/watermark.png b/docs/build/html/_static/watermark.png new file mode 100644 index 0000000..d71dc4b Binary files /dev/null and b/docs/build/html/_static/watermark.png differ diff --git a/docs/build/html/_static/watermark_blur.png b/docs/build/html/_static/watermark_blur.png new file mode 100644 index 0000000..9fc0b6d Binary files /dev/null and b/docs/build/html/_static/watermark_blur.png differ diff --git a/docs/build/html/api.html b/docs/build/html/api.html new file mode 100644 index 0000000..75459e5 --- /dev/null +++ b/docs/build/html/api.html @@ -0,0 +1,111 @@ + + + + + + + +welcome to pyoloads documentation, a python module to help typechecking +and annotaions checking in functions
++ Searching for multiple words only shows matches that contain + all words. +
+ + + + + + +pyoload has two main functions
+Is used as a decorator on the function.
+from pyoload import annotate
+@annotate
+def twice(a:int) -> int:
+ return a * 2
+b = twice(4)
+
The annotate creates a wrapper over the decorated function which checks in for argument types over each function call using pyoload.matchType(val, spec)
.
+The original function is kept in the .__pyod_annotate__
attribute.
Implements function overloading in python via a simple decorator
+from pyoload import overload
+import math
+cache = {}
+
+tan_is_real = lambda v: not (v + 90) % 180 == 0
+
+@overload
+def tan(num:Validator(tan_is_real, opposite=True)):
+ raise ValueError(num)
+
+@overload
+def tan(num:int|float) -> float:
+ return math.tan(num(
+
+tan(6)
+
When an overload is registerred, the function name in the form functionModuleName.functionQualName
is goten using pyoload.get_name(funcOrClass) an annotate is gotten using pyoload.annotate(func, True)
+and a new list of overloads is created and stored in pyoload.__overloads__
dictionarry under it’s name. A reference to the list of annotated overloads is stored in the functions .__pyod_overloads__.
When the function is called, the wrapper tries all the functions registerred to that name to catch a pyoload.InternalAnnotationError. If none ran succesfully, it raises an pyoload.OverloadError.
+All pyoload.annotate and pyoload.overload both support Cast objects
+instances of pyoloas.Cast.
+It uses recursive casting with integrated support for dictionaries, e.g:
+dict[int,tuple[list[float] | float]]
+for a dictionarry mapping of integers to list of floats or floats.
Note
+When a union, e.g int | str is passed to Cast, it tries to cast in each of +the specified types in the listed order, that is
+cast = pyoload.Cast(int|str)
+print(repr(cast(3i))) # Will print `'3i'` as `3i` can not be converted to a complex
+
In addition to supporting normal plain types, +pyoload includes support for generic aliasses of iterable types and some other classes:
+pyoload.Values(iterable)
+e.g Values(“+-*/â€) or Values(range(6))
pyoload.Cast(type)
+Instructs pyoload to cast to the specified type
A string +The string contents will be evaluated as soon as first function call.