mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-01-23 02:14:04 +00:00
move the type difference declaration to pycompat
This commit is contained in:
parent
a73ea14f58
commit
4e9c29cb58
3 changed files with 13 additions and 14 deletions
|
|
@ -5,6 +5,7 @@
|
|||
import abc
|
||||
import os
|
||||
import inspect
|
||||
import sys
|
||||
|
||||
if hasattr(abc, 'ABC'):
|
||||
ABC = abc.ABC
|
||||
|
|
@ -42,3 +43,12 @@ try:
|
|||
iscoroutinefunction = inspect.iscoroutinefunction
|
||||
except AttributeError:
|
||||
iscoroutinefunction = lambda whatever: False # Lolz
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
if PY3:
|
||||
string_types = str,
|
||||
text_type = str
|
||||
else:
|
||||
string_types = basestring,
|
||||
text_type = unicode
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ def get_source_from_frame(frame):
|
|||
if match:
|
||||
encoding = match.group(1).decode('ascii')
|
||||
break
|
||||
source = [utils.text_type(sline, encoding, 'replace') for sline in
|
||||
source = [pycompat.text_type(sline, encoding, 'replace') for sline in
|
||||
source]
|
||||
|
||||
source_cache[cache_key] = source
|
||||
|
|
@ -126,7 +126,7 @@ def get_write_function(output, overwrite):
|
|||
|
||||
class FileWriter(object):
|
||||
def __init__(self, path, overwrite):
|
||||
self.path = utils.text_type(path)
|
||||
self.path = pycompat.text_type(path)
|
||||
self.overwrite = overwrite
|
||||
|
||||
def write(self, s):
|
||||
|
|
|
|||
|
|
@ -4,18 +4,7 @@
|
|||
import abc
|
||||
|
||||
import sys
|
||||
from .pycompat import ABC
|
||||
|
||||
PY2 = sys.version_info[0] == 2
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
if PY3:
|
||||
string_types = str,
|
||||
text_type = str
|
||||
else:
|
||||
string_types = basestring,
|
||||
text_type = unicode
|
||||
|
||||
from .pycompat import ABC, string_types
|
||||
|
||||
MAX_VARIABLE_LENGTH = 100
|
||||
MAX_EXCEPTION_LENGTH = 200
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue