-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmypy_plugin.py
More file actions
33 lines (23 loc) · 843 Bytes
/
mypy_plugin.py
File metadata and controls
33 lines (23 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
We extend attrs to support our configuration classes and fields.
To make mypy happy we need to register these wrapped versions of the `attr` functions,
so that the type checker knows about them.
Without this the `env_field` function would not correctly type check the return value.
See Also
--------
- https://www.attrs.org/en/stable/extending.html#mypy
"""
from mypy.plugin import Plugin
from mypy.plugins.attrs import (
attr_attrib_makers,
attr_class_makers,
)
# This works just like `attr.s`.
attr_class_makers.add("climate_ref._config_helpers.config")
# These are our `attr.ib` makers.
attr_attrib_makers.add("climate_ref._config_helpers.env_field")
class MyPlugin(Plugin): # noqa
# Our plugin does nothing, but it has to exist so this file gets loaded.
pass
def plugin(version): # noqa
return MyPlugin