question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DSL enhancement proposal

See original GitHub issue

As discussed on Piter Py #5 in person. Here is the proposal discussed with @proofit404 .

Things which we do here:

  • Wipe any realization from a story_suite decorated class
  • Use a story suite as a context container. Everything mentioned as steps arguments or results is a context member
  • Allow defining some context members explicitly as class attributes, see PurchaseProduct.payment_allowed
  • Define all steps call signatures and a context member to store its result in
  • Allow validating context members consistency using annotations
  • Allow validating realization methods signatures in runtime using DI, see dry-python/dependencies
  • Allow validating realization methods signatures in import time using a story suite class as a metaclass of the realization class similar to ABCMeta
import decimal
import stories

@stories.story_suite
class PurchaseProduct:
    payment_allowed: bool

    @stories.story
    def purchase(self, user: User, product: Product, shipment_details: ShipmentDetails):
        self.create_order()
        self.calculate_price()
        self.request_payment()
        self.process_payment() if self.payment_allowed else self.reject_payment()
        self.notify_user()

    @stories.step
    def create_order(
        self, user: User, product: Product
    ) -> stories.Success["order", Order]:
        ...

    @stories.step
    def calculate_price(
        self, order: Order
    ) -> stories.Success["price", decimal.Decimal]:
        ...

    @stories.step
    def request_payment(
        self, user: User, order: Order
    ) -> stories.Success["payment_allowed", bool]:
        ...

    @stories.step
    def process_payment(
        self, user: User, price: decimal.Decimal
    ) -> stories.Success["payment_result", PaymentResult]:
        ...

    @stories.step
    def reject_payment(
        self, user: User
    ) -> stories.Success["payment_result", PaymentResult]:
        ...

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
proofit404commented, Nov 23, 2018

I and @sobolevn agreed that some logic in the type hints isn’t the right choice for this library.

Other things listed here are pretty useful. We will implement them eventually but in a different form.

I’ve decided to spit this report into several issues to work on each separately:

0reactions
ligcommented, Nov 4, 2018

@proofit404 shall we build something in public as a POC maybe?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mitigation - Department of State Lands - Oregon.gov
DSL uses a permit application process to document how a proposed project has reduced adverse effects to aquatic resources and how any unavoidable...
Read more >
Create a schema for the new model DSL / data format · Issue #231 ...
This new DSL is already fairly thoroughly documented in Enhancement Proposal EP01 and we have a set of clojure.spec specs for the model...
Read more >
Evolution discussion of the new DSL feature behind SwiftUI ...
... a new enhancement to the Swift language in the form a DSL that ... an evolution proposal document that describes the language...
Read more >
Uni-DSL™: One DSL for Universal Service. - Texas Instruments
Uni-DSL – One DSL for Universal Service – is a new DSL delivery platform proposed by TI and enabled by TI's next-generation DSL...
Read more >
DQS: DSL Quality Management techniques and nomenclature
[9] G.998.4. Improved impulse noise protection for DSL transceivers. ITU-T. 2010. [10] TR-100. ADSL2/ADSL2plus Performance Test Plan. BBF.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found