Django Mypy树桩

emil-fixed-django-stubs的Python项目详细描述


mypy logo

Django框架的PEP484存根

Build StatusChecked with mypy

这个包包含类型stubs和mypy插件,为django框架提供更精确的静态类型和类型推断。django使用了一些python“魔术”,这使得一些代码模式的精确类型成为问题。这就是为什么我们需要在stub中附带mypy插件。最后一个目标是能够获得最常见模式的精确类型。

支持Python3.6/3.7和Django 2.1.x系列。

可以在django的早期版本上运行,但预计会出现一些缺少导入警告的情况。

安装

pip install django-stubs

要让mypy知道这个插件,您需要添加

[mypy]
plugins =
    mypy_django_plugin.main

在您的mypy.ini文件中。

配置

要指定配置文件,请使用配置文件的路径设置MYPY_DJANGO_CONFIG环境变量。默认值是./mypy_django.ini

配置文件格式(.ini):

[mypy_django_plugin]

# specify settings module to use for django.conf.settings, this setting
# could also be specified with DJANGO_SETTINGS_MODULE environment variable
# (it also takes priority over config file)
django_settings = mysettings.local

# if True, all unknown settings in django.conf.settings will fallback to Any,
# specify it if your settings are loaded dynamically to avoid false positives
ignore_missing_settings = True

# if True, unknown attributes on Model instances won't produce errors
ignore_missing_model_attributes = True

获取帮助

我们这里有吉特https://gitter.im/mypy-django/Lobby

如果你认为你有更一般的打字问题,请参考https://github.com/python/mypy和他们的gitter。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何表示1。。Java中的n关系   java在安卓应用程序中添加polaris viewer   Java字符串::replaceAll仅替换第一个出现(可能不正确的正则表达式)   java Tomcat/JBoss部署后脚本   如何在Heroku Java应用程序中运行发出web请求的周期进程   java如何以纳秒为单位证明算法的时间   Solaris上的java自定义ListCellRenderer(使用jre5)   java试图为我的播放器类测试块实现播放器重力(RealtutsGml平台教程)   c#消耗一个。带有java的net web服务未显示预期结果   java在KOI8\R中检索html   基于java图形的搜索与基于随机的搜索   java如何检查安卓设备上的可用空间?在SD卡上?