python / python/mypy

(🎁) Flag to make default return type `None` instead of `Any`

Open
#9,413 27 comments 35 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature needs discussion
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

🚀 Feature

Most other languages(Kotlin, Rust, Swift etc) have a void(or equivalent) return type by default. Can an option be added to have an implicit None return type.

def foo():  # implicit None
  print("hi")

🆕 Update

Basedmypy 1.3 supports this functionality with the --default-return flag.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing mypy's existing option handling and return-type inference, then compare the requested behavior with Basedmypy 1.3's --default-return flag. Done should include a defined command-line option, consistent handling of implicit returns, and tests covering the default and configured behaviors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.