Coder Social home page Coder Social logo

Comments (7)

JelleZijlstra avatar JelleZijlstra commented on July 3, 2024 1

We don't change old PEPs. New examples should either be added to the CPython documentation (in this case, Doc/library/typing.rst) or the typing spec in https://github.com/python/typing.

from cpython.

nineteendo avatar nineteendo commented on July 3, 2024

Do we add it to the PEP, or do we modify the example in the docs?

@overload
def process(response: None) -> None:
    ...
@overload
def process(response: int) -> tuple[int, str]:
    ...
@overload
def process(response: bytes) -> str:
    ...
def process(response):
    ...  # actual implementation goes here

from cpython.

davidlowryduda avatar davidlowryduda commented on July 3, 2024

Do we add it to the PEP, or do we modify the example in the docs?

It's not necessary to write a PEP for this. If you know where you think an example would fit well in the docs, then you can make a pull request with that change. Each pull request should typically cite an issue, and this issue would be a good issue to cite.

from cpython.

nineteendo avatar nineteendo commented on July 3, 2024

No, not a new PEP, I meant adding it to the other examples in the existing PEP: https://peps.python.org/pep-0484/#function-method-overloading.

from cpython.

nineteendo avatar nineteendo commented on July 3, 2024

I suggest we modify the example like this:

@overload
def process(response: None = ...) -> None:
    ...
@overload
def process(response: int) -> tuple[int, str]:
    ...
@overload
def process(response: bytes) -> str:
    ...
def process(response=None):
    ...  # actual implementation goes here

Should we mention overlap as well?

@overload
def unsafe_func(x: int = ...) -> int:
    ...
@overload
def unsafe_func(x: str = ...) -> str:
    ...
def unsafe_func(x = "abc"):
    return x

from cpython.

nineteendo avatar nineteendo commented on July 3, 2024

Do we close this or not? You rejected both my pull requests.

from cpython.

JelleZijlstra avatar JelleZijlstra commented on July 3, 2024

Yes, I don't think there's anything to do here for CPython.

from cpython.

Related Issues (20)

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.