question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document incorrect about 'default_box_attr' behaviour

See original GitHub issue

In 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cdgriffithcommented, Feb 1, 2020
1reaction
cdgriffithcommented, Jan 16, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found