Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
from python_static_type import decorate_static_type, ExceptionStaticType class Test: pass @decorate_static_type def func1(x: int, y: str) -> list: return (x, y) # Указали неправильный тип. @decorate_static_type def func2(*, key: str = '', tuple_var: tuple = (), list_var: list = [[[[]]]]) -> str: return key func2() # Отработает хорошо. try: func1(1, "str") except ExceptionStaticType as e: print(e) # Функция func1: Возвращает неожиданное значение, ожидалось "list" try: func1(y=1, x="2") except ExceptionStaticType as e: print(e) # Функция func1: Аргумент "y" имеет тип "int", а ожидался "str" try: func1('2', 1) except ExceptionStaticType as e: print(e) # Функция func1: Аргумент "x" имеет тип "str", а ожидался "int" try: func1(1, Test) except ExceptionStaticType as e: print(e) # Функция func1: Аргумент "y" имеет тип "type", а ожидался "str". try: func1(1, True) except ExceptionStaticType as e: print(e) # Функция func1: Аргумент "y" имеет тип "bool", а ожидался "str".
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)