make mypy happy

This commit is contained in:
Salvo 'LtWorf' Tomaselli
2017-06-24 11:31:07 +02:00
parent 57936db6b9
commit 2d9bbf39f0
8 changed files with 24 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
# Relational
# Copyright (C) 2009-2016 Salvo "LtWorf" Tomaselli
# Copyright (C) 2009-2017 Salvo "LtWorf" Tomaselli
#
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
# Relational
# Copyright (C) 2008-2016 Salvo "LtWorf" Tomaselli
# Copyright (C) 2008-2017 Salvo "LtWorf" Tomaselli
#
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,6 +24,8 @@
#
# Language definition here:
# http://ltworf.github.io/relational/grammar.html
from typing import Optional
from relational import rtypes
RELATION = 0
@@ -100,8 +102,8 @@ class Node (object):
operation.
This class is used to convert an expression into python code.'''
kind = None
__hash__ = None
kind = None # type: Optional[int]
__hash__ = None # type: None
def __init__(self, expression=None):
'''Generates the tree from the tokenized expression

View File

@@ -1,5 +1,5 @@
# Relational
# Copyright (C) 2008-2016 Salvo "LtWorf" Tomaselli
# Copyright (C) 2008-2017 Salvo "LtWorf" Tomaselli
#
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ class Relation (object):
An empty relation needs a header, and can be filled using the insert()
method.
'''
__hash__ = None
__hash__ = None # type: None
def __init__(self, filename=""):
self._readonly = False

View File

@@ -57,7 +57,7 @@ class Rstring (str):
self._autocast = rdate(self)
return self._autocast
def isInt(self):
def isInt(self) -> bool:
'''Returns true if the string represents an int number
it only considers as int numbers the strings matching
the following regexp:
@@ -65,7 +65,7 @@ class Rstring (str):
'''
return Rstring.int_regexp.match(self) is not None
def isFloat(self):
def isFloat(self) -> bool:
'''Returns true if the string represents a float number
it only considers as float numbers, the strings matching
the following regexp:
@@ -73,7 +73,7 @@ class Rstring (str):
'''
return Rstring.float_regexp.match(self) is not None
def isDate(self):
def isDate(self) -> bool:
'''Returns true if the string represents a date,
in the format YYYY-MM-DD. as separators '-' , '\', '/' are allowed.
As side-effect, the date object will be stored for future usage, so
@@ -159,7 +159,7 @@ class Rdate (object):
return (self.intdate - other.intdate).days
def is_valid_relation_name(name):
def is_valid_relation_name(name: str) -> bool:
'''Checks if a name is valid for a relation.
Returns boolean'''
return re.match(RELATION_NAME_REGEXP, name) != None and not keyword.iskeyword(name)