Document incorrect about 'default_box_attr' behaviour
See original GitHub issueIn document
default_box_attr will first check if it is callable, and will call the object if it is, otherwise it will see if has the copy attribute and will call that, lastly, will just use the provided item as is
But due to Box init
self._box_config.update({
'default_box': default_box,
'default_box_attr': default_box_attr or self.__class__,
When default_box_attr is logical false (‘’, [], {} etc) it’s actually replaced by Box.
This code won’t work as expected:
x = Box(default_box=True, default_box_attr='')
x.abc # returns a Box
It has to be
x = Box(default_box=True, default_box_attr=str)
x.abc # returns ''
So list
for []
, int
for 0
etc
At least version 3.4.6 is working with default_box_attr=''
.
Suggestion:
Either change document to indicate this detail, or change code to accept '', [], 0
etc.
Possible fix is
'default_box_attr': self.__class__ if default_box_attr is None else default_box_attr,
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to Document an Incorrect Behavior in the Workplace
Documenting inappropriate, incorrect or potentially illegal behavior is the first step in evaluating employees who aren't living up to your expectations.
Read more >How To Document Employee Behavior Problems And Correct ...
Today we'll be discussing how to document employee behavior problems and how you can correct them. What Are Employee Behavior Issues? Employee ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
slated for 4.1 https://github.com/cdgriffith/Box/pull/132
First attempt at fix of this in https://github.com/cdgriffith/Box/commit/1eb54789393063093de4ad1847cabbb51efc2d3b
Pinging @iordanivanov on this thread as well now that there is a possible working update.
More test cases are needed for this to confirm I’m not missing anything.