Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
634f4dae
Commit
634f4dae
authored
4 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
small refactor
parent
1b7bdb83
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
satella/coding/decorators/decorators.py
+1
-1
1 addition, 1 deletion
satella/coding/decorators/decorators.py
satella/coding/predicates/decorators.py
+4
-4
4 additions, 4 deletions
satella/coding/predicates/decorators.py
with
5 additions
and
5 deletions
satella/coding/decorators/decorators.py
+
1
−
1
View file @
634f4dae
...
...
@@ -186,7 +186,7 @@ def has_keys(keys: tp.List[str]):
def
short_none
(
clb
:
tp
.
Union
[
Expression
,
tp
.
Callable
[[
T
],
U
]])
->
tp
.
Callable
[
[
tp
.
Optional
[
T
]],
tp
.
Optional
[
U
]]:
[
tp
.
Optional
[
T
]],
tp
.
Optional
[
U
]]:
"""
Accept a callable. Return a callable that executes it only if passed a no-None arg,
and returns its result. If passed a None, return a None
...
...
This diff is collapsed.
Click to expand it.
satella/coding/predicates/decorators.py
+
4
−
4
View file @
634f4dae
...
...
@@ -5,7 +5,7 @@ def p_all(*args: tp.Callable[[tp.Any], bool]) -> tp.Callable[[tp.Any], bool]:
"""
Make a predicate returning True if all specified predicates return True
"""
def
predicate
(
v
):
def
predicate
(
v
)
->
bool
:
return
all
(
arg
(
v
)
for
arg
in
args
)
return
predicate
...
...
@@ -14,7 +14,7 @@ def p_any(*args: tp.Callable[[tp.Any], bool]) -> tp.Callable[[tp.Any], bool]:
"""
Make a predicate returning True if any of specified predicates return True
"""
def
predicate
(
v
):
def
predicate
(
v
)
->
bool
:
return
any
(
arg
(
v
)
for
arg
in
args
)
return
predicate
...
...
@@ -23,7 +23,7 @@ def attribute(attr: str, p: tp.Callable[[tp.Any], bool]) -> tp.Callable[[tp.Any]
"""
Make predicate p refer to attribute of the object passed to it.
"""
def
predicate
(
v
):
def
predicate
(
v
)
->
bool
:
return
p
(
getattr
(
v
,
attr
))
return
predicate
...
...
@@ -34,7 +34,7 @@ def item(i, p: tp.Callable[[tp.Any], bool]) -> tp.Callable[[tp.Any], bool]:
i doesn
'
t have to be an integer, it will be passed to __getitem__
"""
def
predicate
(
v
):
def
predicate
(
v
)
->
bool
:
return
p
(
v
[
i
])
return
predicate
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment