Make bodywidth kwarg overridable using config #84

Merged
merged 1 commit into from Jul 4, 2015

Conversation

3 participants
@emillon

emillon commented Jun 29, 2015

Hey,

I believe I hit a problem with your library.

Default values for arguments are evaluated at import time.
This makes a problem when using html2text the following way:

import html2text  # The default value is evaluated here
html2text.config.BODY_WIDTH = 0
text = html2text.html2text(html)

It is thus necessary to wait until the function runs to fetch the actual
configuration value.

Thanks for maintaining html2text!

@emillon

This comment has been minimized.

Show comment
Hide comment
@emillon

emillon Jun 30, 2015

I'll add a test for this.

emillon commented Jun 30, 2015

I'll add a test for this.

@theSage21

This comment has been minimized.

Show comment
Hide comment
@theSage21

theSage21 Jun 30, 2015

Collaborator

@emillon Thanks for the fix. 😄

Collaborator

theSage21 commented Jun 30, 2015

@emillon Thanks for the fix. 😄

@Alir3z4

This comment has been minimized.

Show comment
Hide comment
@Alir3z4

Alir3z4 Jul 1, 2015

Owner

@emillon Thanks for the patch, please fix the test suite and have a look at https://github.com/Alir3z4/html2text/blob/master/docs/contributing.md

Thanks for the great work.

Owner

Alir3z4 commented Jul 1, 2015

@emillon Thanks for the patch, please fix the test suite and have a look at https://github.com/Alir3z4/html2text/blob/master/docs/contributing.md

Thanks for the great work.

Make bodywidth kwarg overridable using config
Default values for arguments are evaluated at import time.
This makes a problem when using html2text the following way:

    import html2text  # The default value is evaluated here
    html2text.config.BODY_WIDTH = 0
    text = html2text.html2text(html)

It is thus necessary to wait until the function runs to fetch the actual
configuration value.
@emillon

This comment has been minimized.

Show comment
Hide comment
@emillon

emillon Jul 1, 2015

There were no tests for the html2text.html2text function, so I added a third component to what generate_test returns. However, running it for the whole test suite does not work, because most options do not have a kwarg configuration. So I chose to run the "function" variant only for two tests, which adds enough coverage. Let me know what you think.

emillon commented Jul 1, 2015

There were no tests for the html2text.html2text function, so I added a third component to what generate_test returns. However, running it for the whole test suite does not work, because most options do not have a kwarg configuration. So I chose to run the "function" variant only for two tests, which adds enough coverage. Let me know what you think.

Alir3z4 added a commit that referenced this pull request Jul 4, 2015

Merge pull request #84 from emillon/bodywidth-kwarg
Make bodywidth kwarg overridable using config

Thanks @emillon

@Alir3z4 Alir3z4 merged commit e71752d into Alir3z4:master Jul 4, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.27%) to 98.17%
Details

@emillon emillon referenced this pull request in wking/rss2email Jul 4, 2015

Closed

pass BODY_WIDTH as 3rd argument to html2text() #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment