mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-16 05:53:30 -06:00
__defaults__ is available in py27
This commit is contained in:
@@ -5,14 +5,12 @@ import collections
|
||||
import contextlib
|
||||
import os
|
||||
|
||||
from pre_commit import five
|
||||
|
||||
|
||||
UNSET = collections.namedtuple('UNSET', ())()
|
||||
|
||||
|
||||
Var = collections.namedtuple('Var', ('name', 'default'))
|
||||
setattr(Var.__new__, five.defaults_attr, ('',))
|
||||
setattr(Var.__new__, '__defaults__', ('',))
|
||||
|
||||
|
||||
def format_env(parts, env):
|
||||
|
||||
@@ -11,8 +11,6 @@ if PY2: # pragma: no cover (PY2 only)
|
||||
return s
|
||||
else:
|
||||
return s.encode('UTF-8')
|
||||
|
||||
defaults_attr = 'func_defaults'
|
||||
else: # pragma: no cover (PY3 only)
|
||||
text = str
|
||||
|
||||
@@ -22,8 +20,6 @@ else: # pragma: no cover (PY3 only)
|
||||
else:
|
||||
return s.decode('UTF-8')
|
||||
|
||||
defaults_attr = '__defaults__'
|
||||
|
||||
|
||||
def to_text(s):
|
||||
return s if isinstance(s, text) else s.decode('UTF-8')
|
||||
|
||||
Reference in New Issue
Block a user