Last active
April 26, 2019 12:43
-
-
Save erickpeirson/7f38aa69055918972c45a70f9484281c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThePlugin: | |
"""My custom plugin for mypy.""" | |
def get_type_analyze_hook(self, fullname: str) -> Optional[Callable[[AnalyzeTypeContext], Type]]: | |
"""Customize analysis of specific types.""" | |
if fullname == 'somemodule.SomeName': | |
return analyze_some_name | |
return None # mypy will just move on without us. | |
def analyze_some_name(ctx: AnalyzeTypeContext) -> Type: | |
"""The name 'somemodule.SomeName' just refers to str.""" | |
return ctx.api.named_type('builtins.str') | |
def plugin(version: str) -> Type[JSONSchemaPlugin]: | |
"""See `https://mypy.readthedocs.io/en/latest/extending_mypy.html`_.""" | |
return JSONSchemaPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mypy] | |
plugins = myPlugin.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment