Code Monkey home page Code Monkey logo

pynction's Introduction

Hi 👋 My name is Nicolas Nuñez

Backend developer

  • 🌍  I'm based in Mendoza, Argentina ✉️  You can contact me at [email protected]
  • 🚀  I'm currently working on PedidosYa
  • 🧠  I'm learning DDD, Kotlin and Scala

Skills

Python

Python Pytest Flask Django

JVM

Java Kotlin Scala Spock Spring

Databases

MySQL MongoDB

Frontend

HTML5 CSS3 React

Socials

Badges

My GitHub Stats

niconunez96's GitHub stats

Top Repositories








pynction's People

Contributors

nicolasnunez-eb avatar niconunez96 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

pynction's Issues

'do' and static type analysis

thank you for sharing very good library.

in case do_maybe is used to tie two Maybe, 'mypy' compains about return type.

from typing import Any, Tuple, TypeVar, Union
from pynction import just
from pynction.monads.maybe import DoMaybe, Maybe, do as do_maybe

def a() -> Maybe[int]:
    return just(3)

def b() -> Maybe[str]:
    return just("foo")

@do_maybe
def f() -> DoMaybe[Union[int, str], Tuple[int, str]]:
    x = yield a()
    y = yield b()
    return (x, y)
a.py:15: error: Incompatible return value type (got "Tuple[Union[int, str], Union[int, str]]", expected "Tuple[int, str]")
Found 1 error in 1 file (checked 1 source file)

my quick hack made it type safe and able to omit first type parameter of DoMaybe, but need a bit long writing.
is there any better way known?

T = TypeVar("T")

def gen(x: Maybe[T]) -> DoMaybe[T, T]:
    t = yield x
    return t

@do_maybe
def g1() -> DoMaybe[Union[int, str], Tuple[int, str]]:
    x = yield from gen(a())
    y = yield from gen(b())
    return (x, y)  # no error

DoMaybeAny = DoMaybe[Any, T]

@do_maybe
def g2() -> DoMaybeAny[Tuple[int, str]]:
    x = yield from gen(a())
    y = yield from gen(b())
    return (x, y)  # no error

@do_maybe
def g3() -> DoMaybeAny[Tuple[int, str]]:
    x = yield from gen(a())
    y = yield from gen(b())
    return (y, x)  # error Tuple[str, int] vs Tuple[int, str]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.