0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-29 03:04:16 +01:00
posthog/mypy.ini
Tim Glaser 4782d54d1f
Configure mypy (#562)
* server/mypy: Enable no_implicit_optional

no_implicit_optional Changes the treatment of arguments with a default value of None by not implicitly making their type Optional.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#none-and-optional-handling

* server/mypy: Enable warn_unused_ignores

warn_unused_ignores: Warns about unneeded # type: ignore comments.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#configuring-warnings

It's best to exclude packages with no typing in mypy.ini rather than in
the code. This waym if tin the future these packages add types it's can
easily be disabled (by removing the exclusion in mypy.ini).

* api/user: Fix user password was not really validated

* api/test/base: Remove unreachable code

Team is created in setup, so no reason for it not to be there (unless
setUp is overriden by child, which as far as I can see is currently not
happening),

* server/mypy: Enable check_untyped_defs

check_untyped_defs: Type-checks the interior of functions without type annotations.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#untyped-definitions-and-calls

* server/mypy: Enable strict_equality

strict_equality: Prohibit equality checks, identity checks, and container checks between non-overlapping types.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#miscellaneous-strictness-flags

* server/mypy: Enable warn_unreachable

Added a fixme for a possible oversight in function that parses JSON.

warn_unreachable: Shows a warning when encountering any code
inferred to be unreachable or redundant after performing type
analysis.
Ref: https://mypy.readthedocs.io/en/stable/config_file.html#configuring-warnings

* api/posthog: fix possible bug when batch is not a list

Current code assumes batch is a valid list. If batch is not a list, the
capture handling will cause a 500 error.

* fix stricter mypy

* Use response.json instead of .data

Co-authored-by: Haki Benita <hakibenita@gmail.com>
2020-04-14 11:05:45 +01:00

47 lines
862 B
INI

[mypy]
plugins =
mypy_django_plugin.main,
mypy_drf_plugin.main
strict_optional = True
no_implicit_optional = True
warn_unused_ignores = True
check_untyped_defs = True
warn_unreachable = True
strict_equality = True
[mypy.plugins.django-stubs]
django_settings_module = posthog.settings
[mypy-dj_database_url]
ignore_missing_imports = True
[mypy-social_django.models]
ignore_missing_imports = True
[mypy-celery.*]
ignore_missing_imports = True
[mypy-social_django.strategy]
ignore_missing_imports = True
[mypy-social_core.utils]
ignore_missing_imports = True
[mypy-posthoganalytics]
ignore_missing_imports = True
[mypy-drf_yasg]
ignore_missing_imports = True
[mypy-drf_yasg.views]
ignore_missing_imports = True
[mypy-pandas]
ignore_missing_imports = True
[mypy-numpy]
ignore_missing_imports = True
[mypy-freezegun]
ignore_missing_imports = True