From 2d9bbf39f028440ae094db31802421bef7b93550 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sat, 24 Jun 2017 11:31:07 +0200 Subject: [PATCH] make mypy happy --- relational/optimizations.py | 2 +- relational/parser.py | 8 +++++--- relational/relation.py | 4 ++-- relational/rtypes.py | 8 ++++---- relational_gui/about.py | 4 ++-- relational_gui/guihandler.py | 5 ++++- relational_gui/surveyForm.py | 3 +++ relational_readline/linegui.py | 3 +++ 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/relational/optimizations.py b/relational/optimizations.py index e45d4b9..dc66774 100644 --- a/relational/optimizations.py +++ b/relational/optimizations.py @@ -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 diff --git a/relational/parser.py b/relational/parser.py index e47c88b..340ed8a 100644 --- a/relational/parser.py +++ b/relational/parser.py @@ -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 diff --git a/relational/relation.py b/relational/relation.py index 00d99f6..dd88afb 100644 --- a/relational/relation.py +++ b/relational/relation.py @@ -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 diff --git a/relational/rtypes.py b/relational/rtypes.py index 805d9f4..dea4a44 100644 --- a/relational/rtypes.py +++ b/relational/rtypes.py @@ -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) diff --git a/relational_gui/about.py b/relational_gui/about.py index 46bdd3e..4c03c99 100644 --- a/relational_gui/about.py +++ b/relational_gui/about.py @@ -1,5 +1,5 @@ # Relational -# Copyright (C) 2008-2015 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,7 +24,7 @@ try: # If QtWebKit is available, uses it except: webk = False -version = 0 +version = '' class Ui_Dialog(object): diff --git a/relational_gui/guihandler.py b/relational_gui/guihandler.py index 4cb7973..80ff863 100644 --- a/relational_gui/guihandler.py +++ b/relational_gui/guihandler.py @@ -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 @@ -28,6 +28,9 @@ from relational_gui import surveyForm from relational_gui import maingui +version = '' + + class relForm(QtWidgets.QMainWindow): def __init__(self): diff --git a/relational_gui/surveyForm.py b/relational_gui/surveyForm.py index 647b3ca..a638392 100644 --- a/relational_gui/surveyForm.py +++ b/relational_gui/surveyForm.py @@ -24,6 +24,9 @@ from PyQt5 import QtWidgets from relational import maintenance +version = '' + + class surveyForm (QtWidgets.QWidget): '''This class is the form used for the survey, needed to intercept the events. diff --git a/relational_readline/linegui.py b/relational_readline/linegui.py index bfcbcd8..fa4caef 100644 --- a/relational_readline/linegui.py +++ b/relational_readline/linegui.py @@ -35,6 +35,9 @@ COLOR_GREEN = 0x00ff00 TTY = os.isatty(0) and os.isatty(1) +version = '' + + def printtty(*args, **kwargs): ''' Prints only if stdout and stdin are a tty