mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 04:50:20 -06:00
Make Not and NotIn namedtuples
This commit is contained in:
@@ -124,7 +124,7 @@ CONFIG_REPO_DICT = schema.Map(
|
||||
schema.Conditional(
|
||||
'sha', schema.check_string,
|
||||
condition_key='repo',
|
||||
condition_value=schema.NotIn((_LOCAL_SENTINEL, _META_SENTINEL)),
|
||||
condition_value=schema.NotIn(_LOCAL_SENTINEL, _META_SENTINEL),
|
||||
ensure_absent=True,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -201,17 +201,14 @@ class Array(collections.namedtuple('Array', ('of',))):
|
||||
return [remove_defaults(val, self.of) for val in v]
|
||||
|
||||
|
||||
class Not(object):
|
||||
def __init__(self, val):
|
||||
self.val = val
|
||||
|
||||
class Not(collections.namedtuple('Not', ('val',))):
|
||||
def __eq__(self, other):
|
||||
return other is not MISSING and other != self.val
|
||||
|
||||
|
||||
class NotIn(object):
|
||||
def __init__(self, values):
|
||||
self.values = values
|
||||
class NotIn(collections.namedtuple('NotIn', ('values',))):
|
||||
def __new__(cls, *values):
|
||||
return super(NotIn, cls).__new__(cls, values=values)
|
||||
|
||||
def __eq__(self, other):
|
||||
return other is not MISSING and other not in self.values
|
||||
|
||||
Reference in New Issue
Block a user