diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e4ff5c9..216f115 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,5 +1,8 @@ + + \ No newline at end of file diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index 9eb23b7..1fd6284 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -325,7 +325,7 @@ class Tracer: elapsed_time_string = pycompat.timedelta_format(duration) indent = ' ' * 4 * (thread_global.depth + 1) self.write( - '\033[33m'+'{indent}Elapsed time: {elapsed_time_string}'+'\033[0m'.format(**locals()) + '\033[33m' + '{indent}Elapsed time: {elapsed_time_string}' + '\033[0m'.format(**locals()) ) # # ### Finished writing elapsed time. #################################### @@ -426,16 +426,16 @@ class Tracer: for name, value_repr in local_reprs.items(): if name not in old_local_reprs: - str = '{indent}{newish_string}{name} = {value_repr}'.format( **locals()) + str = '{indent}{newish_string}{name} = {value_repr}'.format(**locals()) idx = str.find(":") - if("Start" in str): - self.write('\033[33m' + str[0:idx+3] + '\033[34m' + str[idx+3:] + '\033[0m') + if ("Start" in str): + self.write('\033[33m' + str[0:idx + 3] + '\033[34m' + str[idx + 3:] + '\033[0m') else: - self.write('\033[33m' + str[0:idx+8] + '\033[34m' + str[idx+8:] + '\033[0m') + self.write('\033[33m' + str[0:idx + 8] + '\033[34m' + str[idx + 8:] + '\033[0m') elif old_local_reprs[name] != value_repr: str = '{indent}Modified var:.. {name} = {value_repr}'.format(**locals()) idx = str.find("..") - self.write('\033[33m' + str[0:idx+2] + '\033[34m' + str[idx+2:] + '\033[0m') + self.write('\033[33m' + str[0:idx + 2] + '\033[34m' + str[idx + 2:] + '\033[0m') # # ### Finished newish and modified variables. ########################### @@ -455,7 +455,7 @@ class Tracer: if candidate_source_line.lstrip().startswith('def'): # Found the def line! - # Save line_no and sorce line + # Save line_no and source line line_no = candidate_line_no source_line = candidate_source_line break @@ -483,7 +483,7 @@ class Tracer: idx = str.find(" ") for s in str.split(): - if(s.isdigit()): num = s + if s.isdigit(): num = s numidx = str.find(" " + num + " ") self.write('\033[30m' + str[:idx] + '\033[32m' + str[idx:numidx] + '\033[36m' + str[numidx:] + '\033[0m') @@ -498,7 +498,7 @@ class Tracer: self.max_variable_length, self.normalize, ) - self.write('\033[95m' + '{indent}Return value:.. {return_value_repr}'. + self.write('\033[95m' + '{indent}Return value:.. {name} = {return_value_repr}'. format(**locals()) + '\033[0m') if event == 'exception': diff --git a/pysnooper/variables.py b/pysnooper/variables.py index 2229c38..d286333 100644 --- a/pysnooper/variables.py +++ b/pysnooper/variables.py @@ -1,5 +1,6 @@ import itertools import abc + try: from collections.abc import Mapping, Sequence except ImportError: @@ -47,7 +48,7 @@ class BaseVariable(pycompat.ABC): def __eq__(self, other): return (isinstance(other, BaseVariable) and - self._fingerprint == other._fingerprint) + self._fingerprint == other._fingerprint) class CommonVariable(BaseVariable):