cdgriffith / cdgriffith/Box

How can I provide a Box subclass that automatically sets default_box=True ?

Open
#296 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
2.8k
Forks
135
PR merge metrics
No merged PRs in 30d

Description

Essentially I want the user to _not_ have to use this
```python
empty_box = Box(default_box=True)
```

but rather I want this call:
```python
config = MyConfigClass()
```

to be equivalent to the former.

I tried subclassing Box:

```python
class MyConfigClass(Box):
def __init__(self):
super().__init__(default_box=True)
```

but that throws this error:
```
MyConfigClass.__init__() got an unexpected keyword argument 'default_box'
```

What's the best practice to create a Box subclass with specific non-default values for certain Box options?

Contributor guide

Open the contributing guide

Research direction

Start with the Box constructor and the MyConfigClass example shown in the issue. Determine whether the project supports configuring Box options through subclass initialization or needs documented guidance; done means MyConfigClass() behaves like Box(default_box=True) without requiring the caller to pass the option.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.