Skip to content

Instantly share code, notes, and snippets.

@tsuyukimakoto
Created June 17, 2019 14:18
Show Gist options
  • Select an option

  • Save tsuyukimakoto/224841107b1459e641ec1f694c109f68 to your computer and use it in GitHub Desktop.

Select an option

Save tsuyukimakoto/224841107b1459e641ec1f694c109f68 to your computer and use it in GitHub Desktop.

2019.06.17 22:00+09:00

python3.8にmypyをインストール。まだmasterじゃないとインストールできない。

$ git clone --recurse-submodules https://github.com/python/mypy.git
$ cd mypy
$ python3.8 setup.py install

だがしかし、python3.8は from typing import final で、 mypyはまだ from typing_extensions import final でないとimportできない。

python実行

typing_final1.py

from typing import final

@final
class Spam:
    pass

class Egg(Spam):
    pass

if __name__ == '__main__':
    egg = Egg()
    print(egg)
$ python3.8 typeddicts1.py
<__main__.Egg object at 0x7f3a6f8bce80>

mypyでチェック

typing_final2.py

from typing_extensions import final

@final
class Spam:
    pass

class Egg(Spam):
    pass

if __name__ == '__main__':
    egg = Egg()
    print(egg)
$ mypy typing_final2.py
typing_final2.py:7: error: Cannot inherit from final class "Spam"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment