在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:kracekumar/python-typing-koans开源软件地址:https://github.com/kracekumar/python-typing-koans开源编程语言:Python 100.0%开源软件介绍:Python-typing-koansA set of examples to learn optional static typing in Python. Install
IdeaOne of the best ways to learn python-typing is to annotate the code. In this repo, How to learn?The existing files has no annotations or wrong annotation, as a learner, you run one file and fix each errors till there are no type-errors. In the next section, you will learn, how to list all koans and how to run the modified koan file. All the koan files are present in the following directories koans/py
koans/dj_koans/mysite/polls/koans How to run?
$cat koans/py/100-easy-variable-wrong-type.py
# msg variable is wrongly annotated as int, annotate it as string
msg: int = "hello world!"
# salary is annotated as int, annotate as float
salary: int = 2345.67
# Set is_active as bool
is_active: int = True
$poetry run python cli.py one koans/py/100-easy-variable-wrong-type.py
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Running Mypy on koan file koans/py/100-easy-variable-wrong-type.py
────────────────────────────────── Mypy errors in koan file koans/py/100-easy-variable-wrong-type.py ───────────────────────────────────
koans/py/100-easy-variable-wrong-type.py:2: error: Incompatible types in assignment (expression has type "str", variable has type "int")
msg: int = "hello world!"
^
koans/py/100-easy-variable-wrong-type.py:5: error: Incompatible types in assignment (expression has type "float", variable has type
"int")
salary: int = 2345.67
^
Found 2 errors in 1 file (checked 1 source file)
────────────────────────────────────────────────────────────────── End ──────────────────────────────────────────────────────────────────
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
全部评论
专题导读
上一篇:weirdmeetup/koalabot: nausty nausty koalabot发布时间:2022-06-24下一篇:zaaack/koa-joi-swagger: An opinionated koa validation & swagger library, let ...发布时间:2022-06-24热门推荐
热门话题
阅读排行榜
|
请发表评论