[pypy-commit] pypy default: random whitespace/other cleanup

alex_gaynor noreply at buildbot.pypy.org
Fri Mar 22 06:19:32 CET 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r62642:d425c8bf2b7e
Date: 2013-03-21 22:19 -0700
http://bitbucket.org/pypy/pypy/changeset/d425c8bf2b7e/

Log:	random whitespace/other cleanup

diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -29,13 +29,15 @@
 
 from __future__ import absolute_import
 
-from types import BuiltinFunctionType, MethodType, FunctionType
+import inspect
+import weakref
+from types import BuiltinFunctionType, MethodType
+
 import rpython
 from rpython.tool import descriptor
 from rpython.tool.pairtype import pair, extendabletype
-from rpython.rlib.rarithmetic import r_uint, r_ulonglong, base_int
-from rpython.rlib.rarithmetic import r_singlefloat, r_longfloat
-import inspect, weakref
+from rpython.rlib.rarithmetic import r_uint, base_int, r_singlefloat, r_longfloat
+
 
 class State(object):
     # A global attribute :-(  Patch it with 'True' to enable checking of
@@ -56,8 +58,10 @@
     def __eq__(self, other):
         return (self.__class__ is other.__class__ and
                 self.__dict__  == other.__dict__)
+
     def __ne__(self, other):
         return not (self == other)
+
     def __repr__(self):
         try:
             reprdict = TLS.reprdict
@@ -75,7 +79,7 @@
                     m = getattr(self, 'fmt_' + k, repr)
                     r = m(v)
                     if r is not None:
-                        args.append('%s=%s'%(k, r))
+                        args.append('%s=%s' % (k, r))
                 kwds = ', '.join(args)
             finally:
                 del reprdict[self]
@@ -130,6 +134,7 @@
     def can_be_none(self):
         return False
 
+
 class SomeFloat(SomeObject):
     "Stands for a float or an integer."
     knowntype = float   # if we don't know if it's a float or an int,
@@ -152,6 +157,7 @@
     def can_be_none(self):
         return False
 
+
 class SomeSingleFloat(SomeObject):
     "Stands for an r_singlefloat."
     # No operation supported, not even union with a regular float
@@ -161,6 +167,7 @@
     def can_be_none(self):
         return False
 
+
 class SomeLongFloat(SomeObject):
     "Stands for an r_longfloat."
     # No operation supported, not even union with a regular float
@@ -170,9 +177,11 @@
     def can_be_none(self):
         return False
 
+
 class SomeInteger(SomeFloat):
     "Stands for an object which is known to be an integer."
     knowntype = int
+
     # size is in multiples of C's sizeof(long)!
     def __init__(self, nonneg=False, unsigned=None, knowntype=None):
         assert (knowntype is None or knowntype is int or
@@ -189,25 +198,29 @@
         self.nonneg = unsigned or nonneg
         self.unsigned = unsigned  # rpython.rlib.rarithmetic.r_uint
 
+
 class SomeBool(SomeInteger):
     "Stands for true or false."
     knowntype = bool
     nonneg = True
     unsigned = False
+
     def __init__(self):
         pass
+
     def set_knowntypedata(self, knowntypedata):
         assert not hasattr(self, 'knowntypedata')
         if knowntypedata:
             self.knowntypedata = knowntypedata
 
+
 class SomeStringOrUnicode(SomeObject):
     """Base class for shared implementation of SomeString and SomeUnicodeString.
 
     Cannot be an annotation."""
 
     immutable = True
-    can_be_None=False
+    can_be_None = False
     no_nul = False  # No NUL character in the string.
 
     def __init__(self, can_be_None=False, no_nul=False):
@@ -226,8 +239,10 @@
         d1 = self.__dict__
         d2 = other.__dict__
         if not TLS.check_str_without_nul:
-            d1 = d1.copy(); d1['no_nul'] = 0   # ignored
-            d2 = d2.copy(); d2['no_nul'] = 0   # ignored
+            d1 = d1.copy()
+            d1['no_nul'] = 0
+            d2 = d2.copy()
+            d2['no_nul'] = 0
         return d1 == d2
 
     def nonnoneify(self):
@@ -236,27 +251,34 @@
     def nonnulify(self):
         return self.__class__(can_be_None=self.can_be_None, no_nul=True)
 
+
 class SomeString(SomeStringOrUnicode):
     "Stands for an object which is known to be a string."
     knowntype = str
 
+
 class SomeUnicodeString(SomeStringOrUnicode):
     "Stands for an object which is known to be an unicode string"
     knowntype = unicode
 
+
 class SomeByteArray(SomeStringOrUnicode):
     knowntype = bytearray
 
+
 class SomeChar(SomeString):
     "Stands for an object known to be a string of length 1."
     can_be_None = False
+
     def __init__(self, no_nul=False):    # no 'can_be_None' argument here
         if no_nul:
             self.no_nul = True
 
+
 class SomeUnicodeCodePoint(SomeUnicodeString):
     "Stands for an object known to be a unicode codepoint."
     can_be_None = False
+
     def __init__(self, no_nul=False):    # no 'can_be_None' argument here
         if no_nul:
             self.no_nul = True
@@ -266,11 +288,14 @@
 SomeUnicodeString.basestringclass = SomeUnicodeString
 SomeUnicodeString.basecharclass = SomeUnicodeCodePoint
 
+
 class SomeList(SomeObject):
     "Stands for a homogenous list of any length."
     knowntype = list
+
     def __init__(self, listdef):
         self.listdef = listdef
+
     def __eq__(self, other):
         if self.__class__ is not other.__class__:
             return False
@@ -285,10 +310,12 @@
     def can_be_none(self):
         return True
 
+
 class SomeTuple(SomeObject):
     "Stands for a tuple of known length."
     knowntype = tuple
     immutable = True
+
     def __init__(self, items):
         self.items = tuple(items)   # tuple of s_xxx elements
         for i in items:
@@ -300,11 +327,14 @@
     def can_be_none(self):
         return False
 
+
 class SomeDict(SomeObject):
     "Stands for a dict."
     knowntype = dict
+
     def __init__(self, dictdef):
         self.dictdef = dictdef
+
     def __eq__(self, other):
         if self.__class__ is not other.__class__:
             return False
@@ -323,12 +353,13 @@
         if len(const) < 20:
             return repr(const)
         else:
-            return '{...%s...}'%(len(const),)
+            return '{...%s...}' % (len(const),)
 
 
 class SomeIterator(SomeObject):
     "Stands for an iterator returning objects from a given container."
     knowntype = type(iter([]))  # arbitrarily chose seqiter as the type
+
     def __init__(self, s_container, *variant):
         self.variant = variant
         self.s_container = s_container
@@ -336,6 +367,7 @@
     def can_be_none(self):
         return False
 
+
 class SomeInstance(SomeObject):
     "Stands for an instance of a (user-defined) class."
 
@@ -347,11 +379,13 @@
 
     def fmt_knowntype(self, kt):
         return None
+
     def fmt_classdef(self, cdef):
         if cdef is None:
             return 'object'
         else:
             return cdef.name
+
     def fmt_flags(self, flags):
         if flags:
             return repr(flags)
@@ -444,7 +478,7 @@
         if hasattr(self, 'const'):
             return None
         else:
-            return '{...%s...}'%(len(pbis),)
+            return '{...%s...}' % (len(pbis),)
 
     def fmt_knowntype(self, kt):
         if self.is_constant():
@@ -452,6 +486,7 @@
         else:
             return kt.__name__
 
+
 class SomeBuiltin(SomeObject):
     "Stands for a built-in function or method with special-cased analysis."
     knowntype = BuiltinFunctionType  # == BuiltinMethodType
@@ -470,16 +505,18 @@
     def can_be_none(self):
         return False
 
+
 class SomeBuiltinMethod(SomeBuiltin):
     """ Stands for a built-in method which has got special meaning
     """
     knowntype = MethodType
 
+
 class SomeImpossibleValue(SomeObject):
     """The empty set.  Instances are placeholders for objects that
     will never show up at run-time, e.g. elements of an empty list."""
     immutable = True
-    annotationcolor = (160,160,160)
+    annotationcolor = (160, 160, 160)
 
     def can_be_none(self):
         return False
@@ -487,16 +524,18 @@
 
 s_None = SomePBC([], can_be_None=True)
 s_Bool = SomeBool()
-s_Int  = SomeInteger()
+s_Int = SomeInteger()
 s_ImpossibleValue = SomeImpossibleValue()
 s_Str0 = SomeString(no_nul=True)
 
+
 # ____________________________________________________________
 # weakrefs
 
 class SomeWeakRef(SomeObject):
     knowntype = weakref.ReferenceType
     immutable = True
+
     def __init__(self, classdef):
         # 'classdef' is None for known-to-be-dead weakrefs.
         self.classdef = classdef
@@ -506,6 +545,7 @@
 
 from rpython.rtyper.lltypesystem import llmemory
 
+
 class SomeAddress(SomeObject):
     immutable = True
 
@@ -515,6 +555,7 @@
     def is_null_address(self):
         return self.is_immutable_constant() and not self.const
 
+
 # The following class is used to annotate the intermediate value that
 # appears in expressions of the form:
 # addr.signed[offset] and addr.signed[offset] = value
@@ -531,9 +572,11 @@
 
 from rpython.rtyper.lltypesystem import lltype
 
+
 class SomePtr(SomeObject):
     knowntype = lltype._ptr
     immutable = True
+
     def __init__(self, ll_ptrtype):
         assert isinstance(ll_ptrtype, lltype.Ptr)
         self.ll_ptrtype = ll_ptrtype
@@ -541,13 +584,16 @@
     def can_be_none(self):
         return False
 
+
 class SomeInteriorPtr(SomePtr):
     def __init__(self, ll_ptrtype):
         assert isinstance(ll_ptrtype, lltype.InteriorPtr)
         self.ll_ptrtype = ll_ptrtype
 
+
 class SomeLLADTMeth(SomeObject):
     immutable = True
+
     def __init__(self, ll_ptrtype, func):
         self.ll_ptrtype = ll_ptrtype
         self.func = func
@@ -598,6 +644,7 @@
     (SomeAddress(), llmemory.Address),
 ]
 
+
 def annotation_to_lltype(s_val, info=None):
     from rpython.rtyper.ootypesystem import ootype
 
@@ -633,6 +680,7 @@
 
 ll_to_annotation_map = dict([(ll, ann) for ann, ll in annotation_to_ll_map])
 
+
 def lltype_to_annotation(T):
     from rpython.rtyper.ootypesystem import ootype
 
@@ -660,6 +708,7 @@
     else:
         return s
 
+
 def ll_to_annotation(v):
     if v is None:
         # i think we can only get here in the case of void-returning
@@ -673,12 +722,14 @@
         return SomeInteriorPtr(T)
     return lltype_to_annotation(lltype.typeOf(v))
 
+
 # ____________________________________________________________
 
 class UnionError(Exception):
     """Signals an suspicious attempt at taking the union of
     deeply incompatible SomeXxx instances."""
 
+
 def unionof(*somevalues):
     "The most precise SomeValue instance that contains all the values."
     try:
@@ -694,12 +745,14 @@
             s1 = pair(s1, s2).union()
     return s1
 
+
 # make knowntypedata dictionary
 
 def add_knowntypedata(ktd, truth, vars, s_obj):
     for v in vars:
         ktd[(truth, v)] = s_obj
 
+
 def merge_knowntypedata(ktd1, ktd2):
     r = {}
     for truth_v in ktd1:
@@ -707,6 +760,7 @@
             r[truth_v] = unionof(ktd1[truth_v], ktd2[truth_v])
     return r
 
+
 def not_const(s_obj):
     if s_obj.is_constant() and not isinstance(s_obj, SomePBC):
         new_s_obj = SomeObject.__new__(s_obj.__class__)
@@ -718,6 +772,7 @@
         s_obj = new_s_obj
     return s_obj
 
+
 # ____________________________________________________________
 # internal
 
@@ -733,6 +788,7 @@
             return x
     assert 0, "couldn't get to commonbase of %r and %r" % (cls1, cls2)
 
+
 def missing_operation(cls, name):
     def default_op(*args):
         if args and isinstance(args[0], tuple):
@@ -747,6 +803,7 @@
         return s_ImpossibleValue
     setattr(cls, name, default_op)
 
+
 class HarmlesslyBlocked(Exception):
     """Raised by the unaryop/binaryop to signal a harmless kind of
     BlockedInference: the current block is blocked, but not in a way


More information about the pypy-commit mailing list