summaryrefslogtreecommitdiff
path: root/scalarint.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2018-08-03 22:14:57 +0200
committerAnthon van der Neut <anthon@mnt.org>2018-08-03 22:14:57 +0200
commitdce10fcff1de54121fb8b440b883ef5d3fe2f96a (patch)
tree072b4bd247e6f1cd95c08c7b67fea0fc96f0578e /scalarint.py
parent2966a4f215861fa05e0dc7e0cd53350766e794c6 (diff)
downloadruamel.yaml-dce10fcff1de54121fb8b440b883ef5d3fe2f96a.tar.gz
Apply oitnb and mypy 0.620, then make everything work again0.15.48
Diffstat (limited to 'scalarint.py')
-rw-r--r--scalarint.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/scalarint.py b/scalarint.py
index d609236..2bd605d 100644
--- a/scalarint.py
+++ b/scalarint.py
@@ -5,7 +5,7 @@ from __future__ import print_function, absolute_import, division, unicode_litera
if False: # MYPY
from typing import Text, Any, Dict, List # NOQA
-__all__ = ["ScalarInt", "BinaryInt", "OctalInt", "HexInt", "HexCapsInt"]
+__all__ = ['ScalarInt', 'BinaryInt', 'OctalInt', 'HexInt', 'HexCapsInt']
from .compat import no_limit_int # NOQA
@@ -13,9 +13,9 @@ from .compat import no_limit_int # NOQA
class ScalarInt(no_limit_int):
def __new__(cls, *args, **kw):
# type: (Any, Any, Any) -> Any
- width = kw.pop('width', None) # type: ignore
+ width = kw.pop('width', None) # type: ignore
underscore = kw.pop('underscore', None) # type: ignore
- v = no_limit_int.__new__(cls, *args, **kw) # type: ignore
+ v = no_limit_int.__new__(cls, *args, **kw) # type: ignore
v._width = width
v._underscore = underscore
return v
@@ -24,35 +24,45 @@ class ScalarInt(no_limit_int):
# type: (Any) -> Any
x = type(self)(self + a)
x._width = self._width # type: ignore
- x._underscore = self._underscore[:] if self._underscore is not None else None # type: ignore # NOQA
+ x._underscore = ( # type: ignore
+ self._underscore[:] if self._underscore is not None else None # type: ignore
+ ) # NOQA
return x
def __ifloordiv__(self, a): # type: ignore
# type: (Any) -> Any
x = type(self)(self // a)
x._width = self._width # type: ignore
- x._underscore = self._underscore[:] if self._underscore is not None else None # type: ignore # NOQA
+ x._underscore = ( # type: ignore
+ self._underscore[:] if self._underscore is not None else None # type: ignore
+ ) # NOQA
return x
def __imul__(self, a): # type: ignore
# type: (Any) -> Any
x = type(self)(self * a)
x._width = self._width # type: ignore
- x._underscore = self._underscore[:] if self._underscore is not None else None # type: ignore # NOQA
+ x._underscore = ( # type: ignore
+ self._underscore[:] if self._underscore is not None else None # type: ignore
+ ) # NOQA
return x
def __ipow__(self, a): # type: ignore
# type: (Any) -> Any
x = type(self)(self ** a)
x._width = self._width # type: ignore
- x._underscore = self._underscore[:] if self._underscore is not None else None # type: ignore # NOQA
+ x._underscore = ( # type: ignore
+ self._underscore[:] if self._underscore is not None else None # type: ignore
+ ) # NOQA
return x
def __isub__(self, a): # type: ignore
# type: (Any) -> Any
x = type(self)(self - a)
x._width = self._width # type: ignore
- x._underscore = self._underscore[:] if self._underscore is not None else None # type: ignore # NOQA
+ x._underscore = ( # type: ignore
+ self._underscore[:] if self._underscore is not None else None # type: ignore
+ ) # NOQA
return x
@@ -71,8 +81,10 @@ class OctalInt(ScalarInt):
# mixed casing of A-F is not supported, when loading the first non digit
# determines the case
+
class HexInt(ScalarInt):
"""uses lower case (a-f)"""
+
def __new__(cls, value, width=None, underscore=None):
# type: (Any, Any, Any) -> Any
return ScalarInt.__new__(cls, value, width=width, underscore=underscore)
@@ -80,6 +92,7 @@ class HexInt(ScalarInt):
class HexCapsInt(ScalarInt):
"""uses upper case (A-F)"""
+
def __new__(cls, value, width=None, underscore=None):
# type: (Any, Any, Any) -> Any
return ScalarInt.__new__(cls, value, width=width, underscore=underscore)