python-attrs / python-attrs/attrs

How to initialize an instance where all fields are default values?

Open
#1,169 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.8k
Forks
480
Avg merge
2h 15m
Merged PRs (30d)
2

Description

How to initialize an instance where all fields are default values?

I don't want to add a default value to each field, and I want each field to automatically get a zero value by default.

This would make dataclass much like struct in the go language.

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 clarifying the intended zero-value behavior for attrs dataclass fields and how it should differ from explicitly declared defaults. The issue names no files, tests, or entry points; done would require an agreed design and tests covering initialization of fields without individual defaults.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.