Skip to content

Commit

Permalink
Add type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
thombashi committed Apr 15, 2020
1 parent 9bf7749 commit 1a3a06f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions typepy/type/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"""

import abc
from typing import Any
from typing import Any, Optional

from .._typecode import Typecode
from ..checker._interface import TypeCheckerInterface
from ..converter import ValueConverterInterface
from ..error import TypeConversionError
Expand All @@ -21,7 +22,7 @@ class AbstractType(TypeCheckerInterface, ValueConverterInterface):
)

@abc.abstractproperty
def typecode(self): # pragma: no cover
def typecode(self) -> Typecode: # pragma: no cover
pass

@abc.abstractmethod
Expand All @@ -44,7 +45,7 @@ def __init__(self, value: Any, strict_level: int, **kwargs) -> None:
self.__checker = self._create_type_checker()
self.__converter = self._create_type_converter()

self.__is_type_result = None
self.__is_type_result = None # type: Optional[bool]

def __repr__(self) -> str:
return ", ".join(
Expand All @@ -70,7 +71,7 @@ def is_type(self) -> bool:

return self.__is_type_result

def __is_type(self):
def __is_type(self) -> bool:
if self.__checker.is_type():
return True

Expand All @@ -87,7 +88,7 @@ def __is_type(self):

return True

def validate(self, error_message=None):
def validate(self, error_message: Optional[str] = None) -> None:
"""
:raises TypeError:
If the value is not matched the type that the class represented.
Expand Down

0 comments on commit 1a3a06f

Please sign in to comment.