-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a get_additional_deps hook to Plugin to support django-stubs (#6598)
django-stubs needs to be able to add in additional dependencies to modules and is currently using monkeypatching to do it. That is 1) not great and 2) breaks under mypyc. Add a hook to support generating additional dependencies from a plugin.
- Loading branch information
Showing
5 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Optional, Callable, List, Tuple | ||
|
||
from mypy.plugin import Plugin | ||
from mypy.nodes import MypyFile | ||
|
||
|
||
class DepsPlugin(Plugin): | ||
def get_additional_deps(self, file: MypyFile) -> List[Tuple[int, str, int]]: | ||
if file.fullname() == '__main__': | ||
return [(10, 'err', -1)] | ||
return [] | ||
|
||
|
||
def plugin(version): | ||
return DepsPlugin |