Dropbox is a big user of Python. It’s our most widely used language both for backend services and the desktop client app (we are also heavy users of Go, TypeScript, and Rust). At our scale—millions of lines of Python—the dynamic typing in Python made code needlessly hard to understand and started to seriously impact productivity. To mitigate this, we have been gradually migrating our code to stati
Type hints cheat sheet¶ This document is a quick cheat sheet showing how to use type annotations for various common types in Python. Variables¶ Technically many of the type annotations shown below are redundant, since mypy can usually infer the type of a variable from its value. See Type inference and type annotations for more details. # This is how you declare the type of a variable age: int = 1
One of the larger features added to Python over the last few releases is support for static typing in the language. Static type-checking and tools to support it show up frequently as topics at the Python Language Summit (PLS) and this year was no exception. Mypy developers Jukka Lehtosalo and Ivan Levkivskyi gave an update on static typing at PLS 2018. Lehtosalo started things off by talking about
The document describes various probability distributions that can arise from combining Bernoulli random variables. It shows how a binomial distribution emerges from summing Bernoulli random variables, and how Poisson, normal, chi-squared, exponential, gamma, and inverse gamma distributions can approximate the binomial as the number of Bernoulli trials increases. Code examples in R are provided to
Generics¶ This section explains how you can define your own generic classes that take one or more type arguments, similar to built-in types such as list[T]. User-defined generics are a moderately advanced feature and you can get far without ever using them – feel free to skip this section and come back later. Defining generic classes¶ The built-in collection classes are generic classes. Generic ty
今年はアドベントカレンダーにも参加していないし、こたつに入ってだらだら過ごそうかと思っていたら、なんか書けと煽られました。年末ですね。 @tk0miya qiita の記事まだー?— Tetsuya Morimoto (@t2y) 2016年12月25日 何を書こうか思考をめぐらした結果、mypy を Sphinx に導入した話でも書くことにします。 mypy については @t2y の 紹介記事 、翻訳記事が非常に参考になりました。 ですので、この記事は @t2y へのアンサーソングです。 なお、「導入した話」と名付けてはみたものの、まだ 100% 対応したというわけではないので、試行錯誤の様子と愚痴を書き留めていきます。 Sphinx に type annotation をつけてみた Sphinx では現在、 master ブランチに対して type annotation がつけられてい
The mypy command line¶ This section documents mypy’s command line interface. You can view a quick summary of the available flags by running mypy --help. Note that directories are checked recursively. Mypy also lets you specify what code to type check in several other ways. A short summary of the relevant flags is included below: for full details, see Running mypy and managing imports. -m MODULE, -
最近mypyを趣味で使い始めたのでいろいろ書こうと思います。 @tk0miiyka さんの記事を読んでとりあえず自分の仕事でmypy使えそうなところをいろいろ考えてみた 対象バージョン version python 3.5.2 mypy 0.4.6 last update 2017.01.08 TL;DR pyiファイルをつくれば世の中の型ヒントが提供されていないプロジェクトに型ヒントをつけられる。 まーでも結構めんどいので、みんなでtypeshedを育てていくのがよさそうです。 GitHub - python/typeshed: Collection of library stubs for Python, with static types mypyって? こちらの素晴らしい記事を読んだほうがいいですね。 qiita.com 要はPython3.4以降で使える静的型チェッカーらしい。個
これらのアノテーションは実行時に普通の __annotations__ 属性として参照できる一方で、 実行時には型チェックを行いません 。その代わり、この提案は独立したオフライン型チェッカーの存在を仮定しています。ユーザーはそのような型チェッカーを使って自主的にソースコードを検査できます。基本的にこういった型チェッカーは非常に強力なリンター (linter) として機能します。(もちろん似たようなチェッカーを使って個々のユーザー向けに契約による設計 (Design By Contract) の強制や JIT 最適化を実行時に行うこともできるはずですが、そういったツールはまだ実用レベルにはなっていません。) この提案は mypy [mypy] に強く触発されています。例えば、"整数型のシーケンス" の型は Sequence[int] のように記述します。角括弧を使うことで言語に新しい構文を追
Updates about mypy, an optional static type checker for Python We’ve just uploaded mypy 0.520 to PyPI. This release includes new features, bug fixes and library stub (typeshed) updates. You can install it as follows: python3 -m pip install --upgrade mypy We are always happy to answer questions on Gitter — note that we’ve moved to a new channel, python/typing. Major New Features Fine-grained Contro
Engineering Static types in Python, oh my(py)! Tim Abbott Oct 13, 2016 • 18 min read Over the last few years, static type checkers have become available for popular dynamic languages like PHP (Hack) and JavaScript (Flow and TypeScript), and have seen wide adoption. Two years ago, a provisional syntax for static type annotations was added to Python 3. However, static types in Python have yet to be
Stefan Behnel stefan_ml at behnel.de Sat Jul 13 07:32:38 CEST 2013 Previous message: [Cython] Py3 annotation syntax for static typing Next message: [Cython] getting rid of redundancy in the docs Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] Jukka Lehtosalo, 12.07.2013 14:03: >> On Thu, Jul 11, 2013 at 6:52 PM, Stefan Behnel wrote: > http://mypy-lang.blogspot.de/2013/07/mypy-switch
Updates about mypy, an optional static type checker for Python Several projects have tried to fix the inefficiency of CPython, with varying degrees of success. The most notable of these is PyPy, which is a JIT compiler for Python (among other things). Mypy is different from the previous projects in several ways, and I believe that these differences are the keys to understanding why I chose the myp
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く