-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from jacebrowning/release/v0.4
Release v0.4
- Loading branch information
Showing
34 changed files
with
426 additions
and
276 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ omit = | |
.venv/* | ||
*/tests/* | ||
*/__main__.py | ||
datafiles/plugins.py | ||
|
||
[report] | ||
|
||
|
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
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,38 @@ | ||
# pylint: disable=no-name-in-module,no-self-use,unused-argument | ||
|
||
from typing import Callable, Optional | ||
|
||
from mypy.nodes import MDEF, SymbolTableNode, Var | ||
from mypy.plugin import ClassDefContext, Plugin | ||
from mypy.plugins.dataclasses import DataclassTransformer | ||
from mypy.types import AnyType, TypeOfAny | ||
|
||
|
||
class DatafilesPlugin(Plugin): | ||
def get_class_decorator_hook( | ||
self, fullname: str | ||
) -> Optional[Callable[[ClassDefContext], None]]: | ||
if fullname.endswith('.datafile'): | ||
return datafile_class_maker_callback | ||
return None | ||
|
||
|
||
def datafile_class_maker_callback(ctx: ClassDefContext) -> None: | ||
# Inherit all type definitions from dataclasses | ||
DataclassTransformer(ctx).transform() | ||
|
||
# Define 'objects' as a class propery | ||
var = Var('objects', AnyType(TypeOfAny.unannotated)) | ||
var.info = ctx.cls.info | ||
var.is_property = True | ||
ctx.cls.info.names[var.name()] = SymbolTableNode(MDEF, var) | ||
|
||
# Define 'datafile' as an instance property | ||
var = Var('datafile', AnyType(TypeOfAny.unannotated)) | ||
var.info = ctx.cls.info | ||
var.is_property = True | ||
ctx.cls.info.names[var.name()] = SymbolTableNode(MDEF, var) | ||
|
||
|
||
def mypy(version: str): | ||
return DatafilesPlugin |
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
Oops, something went wrong.