FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Functions annotated to return None can't return function calls returning None · Issue #2828 · python/mypy · GitHub

Repository navigation

Functions annotated to return None can't return function calls returning None #2828

Closed

Description

Minimal example:

def fn1() -> None:
    return None

def fn2() -> None:
    return fn1() # test.py:5: error: No return value expected

Sorry for the poor issue naming, not sure how else to describe this.

Activity

  1. TRManderson commented on Feb 8, 2017

    ContributorAuthor

    One of the tests explicitly disallows this, which is the cause for my PR #2829 failing. I've removed it in the PR, but is there a reason to have it there in the first place?

  2. JukkaL commented on Feb 24, 2017

    Collaborator

    I have a feeling that this has been discussed earlier. Anyway, it's a matter of style -- the code is clearly correct. I wonder if @gvanrossum has an opinion whether fn2 should be accepted.

  3. gvanrossum commented on Feb 25, 2017

    Member

    I'm torn, since I sometimes do this myself, but I do think it's a (very slight) code smell. I also think that fn1() and fn2() should either both be errors or both pass (both have a -> None and a return EXPR where EXPR is known to have the value None).

  4. ddfisher commented on Feb 27, 2017

    Collaborator

    For what it's worth, this is allowed with --strict-optional.

  5. JukkaL commented on Feb 28, 2017

    Collaborator

    If it's only a very slight code smell, mypy should perhaps not complain about it.

  6. gvanrossum commented on Feb 28, 2017

    Member
  7. msullivan commented on Jan 28, 2020

    Collaborator

    This is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL