@proofit404
it is unclear how to do Skip, Failure and Result behavior without explicit return
I was thinking about a possibility to use exceptions inside a realization code.Skip
could be achieved in a more declarative way using if…else
inside the story definition.
While Failure
looks like a good fit for raise Failure
inside a realization.
@proofit404
shall we build something in public as a POC maybe?
What do you think? An example project which is actually real could serve as a public customer for the stories
library and would be a good place to showcase real cases.
if...else
case will make the code less declarative. Because they are imperative by their nature. What do I mean? You need some in-place data manipulation in order to define if
statement. So we will enforce users to write some-what complex logic in steps definitions. And we may open this method for impure parts including database queries, http calls, etc.
Yeap, I have seen that. But, thanks for sharing anyways!
Maybe I still don't have enough context, but update_article_post
/update_video_post
separation seems like an implementation detail to me. I would personally just go with update_post
. And inside this regular function there might be a separation between post types, etc.
What was your motivation?
@proofit404
@sobolevn To give you more context about
if/else
discussion dry-python/stories#76
with
thing looks nice
It still unclear to me, how to deal with Result (raise Result(1)) seems so ugly.
Is Result just a return which is already declared in a stub method?
well, I need to try so called "a la property" approach
lig
> <@gitter_proofit404:matrix.org> Hi guys, I post some updates on substories conditionals dry-python/stories#76
looks promising. need to try it.
lig
Artem Malyshev (Gitter): I wonder is it possible to use anything instead of I
? So, self
would also be possible to use
>>
syntax. Will it work well with all of these stuff? https://docs.python.org/3/reference/expressions.html#operator-precedence
when(next(Instance(x, 4, force=True)) >> ...
?
And one more question. In languages where we have pattern matching out of the box, we can control how left side is built. What can we do here to limit different user attempts to write something like:
when(next(Instance(x, 4, force=True)) >> ...
?
Sorry, did not see it on my mobile. I think we should not restrict this. The only thing we care is a reference to the value. If user care about code readability, he/she will not write function calls inside when
. If the user does not care, what is the point to use dsl in the first place?
==
against value is not enough, user can pass a predicate function.
django
wemake-services/wemake-django-template#565 2. setup.py
replacement https://github.com/wemake-services/wemake-python-styleguide