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
e23484de
Commit
e23484de
authored
4 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
fixed `source_to_function`
parent
dfc1fc2c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/misc.py
+3
-3
3 additions, 3 deletions
satella/coding/misc.py
tests/test_coding/test_predicates.py
+5
-1
5 additions, 1 deletion
tests/test_coding/test_predicates.py
with
10 additions
and
5 deletions
CHANGELOG.md
+
1
−
0
View file @
e23484de
...
@@ -2,3 +2,4 @@
...
@@ -2,3 +2,4 @@
*
updated docs for
`Loadable.refresh`
*
updated docs for
`Loadable.refresh`
*
added
`DefaultDict`
*
added
`DefaultDict`
*
fixed
`source_to_function`
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
e23484de
__version__
=
'
2.14.20
_a3
'
__version__
=
'
2.14.20
'
This diff is collapsed.
Click to expand it.
satella/coding/misc.py
+
3
−
3
View file @
e23484de
...
@@ -113,12 +113,12 @@ def source_to_function(src: tp.Union[tp.Callable, str]) -> tp.Callable[[tp.Any],
...
@@ -113,12 +113,12 @@ def source_to_function(src: tp.Union[tp.Callable, str]) -> tp.Callable[[tp.Any],
:param src: a callable or a Python string expression
:param src: a callable or a Python string expression
:return: a callable
:return: a callable
"""
"""
if
callable
(
src
):
if
isinstance
(
src
,
str
):
return
src
else
:
q
=
dict
(
globals
())
q
=
dict
(
globals
())
exec
(
'
_precond = lambda x:
'
+
src
,
q
)
exec
(
'
_precond = lambda x:
'
+
src
,
q
)
return
q
[
'
_precond
'
]
return
q
[
'
_precond
'
]
else
:
return
src
def
update_attr_if_none
(
obj
:
object
,
attr
:
str
,
value
:
tp
.
Any
,
def
update_attr_if_none
(
obj
:
object
,
attr
:
str
,
value
:
tp
.
Any
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_coding/test_predicates.py
+
5
−
1
View file @
e23484de
import
unittest
import
unittest
from
satella.coding
import
source_to_function
from
satella.coding.predicates
import
x
,
build_structure
from
satella.coding.predicates
import
x
,
build_structure
class
TestPredicates
(
unittest
.
TestCase
):
class
TestPredicates
(
unittest
.
TestCase
):
def
test_source_to_function
(
self
):
y
=
source_to_function
(
x
)
self
.
assertEqual
(
y
(
5
),
5
)
def
test_build_structure
(
self
):
def
test_build_structure
(
self
):
a
=
{
x
:
x
*
2
}
a
=
{
x
:
x
*
2
}
b
=
[
x
,
x
*
2
,
x
*
3
]
b
=
[
x
,
x
*
2
,
x
*
3
]
...
...
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