gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] branch master updated: resolving conflict betw


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated: resolving conflict between mypy and Python itself
Date: Thu, 07 Dec 2017 15:23:21 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository bank.

The following commit(s) were added to refs/heads/master by this push:
     new b2ea43b  resolving conflict between mypy and Python itself
b2ea43b is described below

commit b2ea43b7ccba2f5dd191185f7eb86edff69d9137
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Dec 7 15:22:12 2017 +0100

    resolving conflict between mypy and Python itself
---
 talerbank/app/amount.py  |  8 +++----
 talerbank/talerconfig.py | 57 ++++++++++++++++++++++++------------------------
 2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/talerbank/app/amount.py b/talerbank/app/amount.py
index 45e306e..c3e2b93 100644
--- a/talerbank/app/amount.py
+++ b/talerbank/app/amount.py
@@ -62,7 +62,7 @@ class Amount:
     # Parse a string matching the format "A:B.C"
     # instantiating an amount object.
     @classmethod
-    def parse(cls: Type[Amount], amount_str: str) -> Amount:
+    def parse(cls, amount_str: str):
         exp = r'^\s*([-_*A-Za-z0-9]+):([0-9]+)\.([0-9]+)\s*$'
         import re
         parsed = re.search(exp, amount_str)
@@ -79,7 +79,7 @@ class Amount:
     # 0 if a == b
     # 1 if a > b
     @staticmethod
-    def cmp(am1: Amount, am2: Amount) -> int:
+    def cmp(am1, am2) -> int:
         if am1.currency != am2.currency:
             raise CurrencyMismatch(am1.currency, am2.currency)
         if am1.value == am2.value:
@@ -98,7 +98,7 @@ class Amount:
         self.fraction = fraction
 
     # Add the given amount to this one
-    def add(self, amount: Amount) -> None:
+    def add(self, amount) -> None:
         if self.currency != amount.currency:
             raise CurrencyMismatch(self.currency, amount.currency)
         self.value += amount.value
@@ -106,7 +106,7 @@ class Amount:
         self.__normalize()
 
     # Subtract passed amount from this one
-    def subtract(self, amount: Amount) -> None:
+    def subtract(self, amount) -> None:
         if self.currency != amount.currency:
             raise CurrencyMismatch(self.currency, amount.currency)
         if self.fraction < amount.fraction:
diff --git a/talerbank/talerconfig.py b/talerbank/talerconfig.py
index 41ebf44..5d42adc 100644
--- a/talerbank/talerconfig.py
+++ b/talerbank/talerconfig.py
@@ -93,33 +93,8 @@ def expand(var: str, getter: Callable[[str], str]) -> str:
     return result + var[pos:]
 
 
-class OptionDict(collections.defaultdict):
-    def __init__(self, config: SectionDict, section_name: str) -> None:
-        self.config = weakref.ref(config)
-        self.section_name = section_name
-        super().__init__()
-    def __missing__(self, key: str) -> Entry:
-        entry = Entry(self.config(), self.section_name, key)
-        self[key] = entry
-        return entry
-    def __getitem__(self, chunk: str) -> Entry:
-        return super().__getitem__(chunk.lower())
-    def __setitem__(self, chunk: str, value: Entry) -> None:
-        super().__setitem__(chunk.lower(), value)
-
-
-class SectionDict(collections.defaultdict):
-    def __missing__(self, key):
-        value = OptionDict(self, key)
-        self[key] = value
-        return value
-    def __getitem__(self, chunk: str) -> OptionDict:
-        return super().__getitem__(chunk.lower())
-    def __setitem__(self, chunk: str, value: OptionDict) -> None:
-        super().__setitem__(chunk.lower(), value)
-
 class Entry:
-    def __init__(self, config: SectionDict, section: str, option: str, 
**kwargs) -> None:
+    def __init__(self, config, section: str, option: str, **kwargs) -> None:
         self.value = kwargs.get("value")
         self.filename = kwargs.get("filename")
         self.lineno = kwargs.get("lineno")
@@ -180,6 +155,32 @@ class Entry:
         return "%s:%s" % (self.filename, self.lineno)
 
 
+class OptionDict(collections.defaultdict):
+    def __init__(self, config, section_name: str) -> None:
+        self.config = weakref.ref(config)
+        self.section_name = section_name
+        super().__init__()
+    def __missing__(self, key: str) -> Entry:
+        entry = Entry(self.config(), self.section_name, key)
+        self[key] = entry
+        return entry
+    def __getitem__(self, chunk: str) -> Entry:
+        return super().__getitem__(chunk.lower())
+    def __setitem__(self, chunk: str, value: Entry) -> None:
+        super().__setitem__(chunk.lower(), value)
+
+
+class SectionDict(collections.defaultdict):
+    def __missing__(self, key):
+        value = OptionDict(self, key)
+        self[key] = value
+        return value
+    def __getitem__(self, chunk: str) -> OptionDict:
+        return super().__getitem__(chunk.lower())
+    def __setitem__(self, chunk: str, value: OptionDict) -> None:
+        super().__setitem__(chunk.lower(), value)
+
+
 class TalerConfig:
     """
     One loaded taler configuration, including base configuration
@@ -194,7 +195,7 @@ class TalerConfig:
     # defaults != config file: the first is the 'base'
     # whereas the second overrides things from the first.
     @staticmethod
-    def from_file(filename=None, load_defaults=True) -> TalerConfig:
+    def from_file(filename=None, load_defaults=True):
         cfg = TalerConfig()
         if filename is None:
             xdg = os.environ.get("XDG_CONFIG_HOME")
@@ -237,7 +238,7 @@ class TalerConfig:
         LOGGER.warning("no base directory found")
 
     @staticmethod
-    def from_env(*args, **kwargs) -> TalerConfig:
+    def from_env(*args, **kwargs):
         """
         Load configuration from environment variable TALER_CONFIG_FILE
         or from default location if the variable is not set.

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]