Skip to content

Commit e338a0c

Browse files
committed
Remove shorthand arguments to Property, Wild and Keys selectors
1 parent c7a10af commit e338a0c

File tree

2 files changed

+7
-36
lines changed

2 files changed

+7
-36
lines changed

jsonpath/parse.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ def parse_selectors(self, stream: TokenStream) -> tuple[JSONPathSelector, ...]:
356356
env=self.env,
357357
token=token,
358358
name=token.value,
359-
shorthand=True,
360359
),
361360
)
362361

@@ -365,7 +364,6 @@ def parse_selectors(self, stream: TokenStream) -> tuple[JSONPathSelector, ...]:
365364
WildSelector(
366365
env=self.env,
367366
token=token,
368-
shorthand=True,
369367
),
370368
)
371369

@@ -374,7 +372,6 @@ def parse_selectors(self, stream: TokenStream) -> tuple[JSONPathSelector, ...]:
374372
KeysSelector(
375373
env=self.env,
376374
token=token,
377-
shorthand=True,
378375
),
379376
)
380377

@@ -422,25 +419,16 @@ def parse_bracketed_selection(self, stream: TokenStream) -> List[JSONPathSelecto
422419
env=self.env,
423420
token=token,
424421
name=self._decode_string_literal(token),
425-
shorthand=False,
426422
),
427423
)
428424
stream.next()
429425
elif token.kind == TOKEN_COLON:
430426
selectors.append(self.parse_slice(stream))
431427
elif token.kind == TOKEN_WILD:
432-
selectors.append(
433-
WildSelector(
434-
env=self.env,
435-
token=token,
436-
shorthand=False,
437-
)
438-
)
428+
selectors.append(WildSelector(env=self.env, token=token))
439429
stream.next()
440430
elif token.kind == TOKEN_KEYS:
441-
selectors.append(
442-
KeysSelector(env=self.env, token=token, shorthand=False)
443-
)
431+
selectors.append(KeysSelector(env=self.env, token=token))
444432
stream.next()
445433
elif token.kind == TOKEN_FILTER:
446434
selectors.append(self.parse_filter_selector(stream))

jsonpath/selectors.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,11 @@ def resolve_async(self, node: JSONPathMatch) -> AsyncIterable[JSONPathMatch]:
5656
class PropertySelector(JSONPathSelector):
5757
"""A shorthand or bracketed property selector."""
5858

59-
__slots__ = ("name", "shorthand")
59+
__slots__ = ("name",)
6060

61-
def __init__(
62-
self,
63-
*,
64-
env: JSONPathEnvironment,
65-
token: Token,
66-
name: str,
67-
shorthand: bool,
68-
) -> None:
61+
def __init__(self, *, env: JSONPathEnvironment, token: Token, name: str) -> None:
6962
super().__init__(env=env, token=token)
7063
self.name = name
71-
self.shorthand = shorthand
7264

7365
def __str__(self) -> str:
7466
return canonical_string(self.name)
@@ -190,13 +182,10 @@ class KeysSelector(JSONPathSelector):
190182
NOTE: This is a non-standard selector.
191183
"""
192184

193-
__slots__ = ("shorthand",)
185+
__slots__ = ()
194186

195-
def __init__(
196-
self, *, env: JSONPathEnvironment, token: Token, shorthand: bool
197-
) -> None:
187+
def __init__(self, *, env: JSONPathEnvironment, token: Token) -> None:
198188
super().__init__(env=env, token=token)
199-
self.shorthand = shorthand
200189

201190
def __str__(self) -> str:
202191
return self.env.keys_selector_token
@@ -298,13 +287,7 @@ async def resolve_async(self, node: JSONPathMatch) -> AsyncIterable[JSONPathMatc
298287
class WildSelector(JSONPathSelector):
299288
"""Select all items from a sequence/array or values from a mapping/object."""
300289

301-
__slots__ = ("shorthand",)
302-
303-
def __init__(
304-
self, *, env: JSONPathEnvironment, token: Token, shorthand: bool
305-
) -> None:
306-
super().__init__(env=env, token=token)
307-
self.shorthand = shorthand
290+
__slots__ = ()
308291

309292
def __str__(self) -> str:
310293
return "*"

0 commit comments

Comments
 (0)