Skip to content

Avoid mutable defaults in MeltingTemp.py - #2213

Merged
peterjc merged 1 commit into
biopython:masterfrom
peterjc:melting_default
Aug 27, 2019
Merged

peterjc merged 1 commit into
biopython:masterfrom
peterjc:melting_default

Conversation

@peterjc

@peterjc peterjc commented Aug 14, 2019

Copy link
Copy Markdown
Member

In addition to a stylistic improvement (mutable defaults are bad), this pull request addresses an issue noted by @MarkusPiotrowski on #2172:

This also helps with the API documentation presentation, as both epydoc and sphinx would show the dictionary in the function signature (although epydoc does abbreviate it):

https://biopython.org/DIST/docs/api/Bio.SeqUtils.MeltingTemp-module.html#Tm_NN

https://biopython.org/docs/1.74/api/Bio.SeqUtils.MeltingTemp.html#Bio.SeqUtils.MeltingTemp.Tm_NN

  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file, have run flake8 locally, and
    understand that AppVeyor and TravisCI will be used to confirm the Biopython unit
    tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

This also helps with the API documentation presentation, as
both epydoc and sphinx would show the dictionary in the function
signature (epydoc does abbreviate it).
@codecov

codecov Bot commented Aug 14, 2019

Copy link
Copy Markdown

Codecov Report

Merging #2213 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2213      +/-   ##
=========================================
+ Coverage   84.69%   84.7%   +<.01%     
=========================================
  Files         317     317              
  Lines       51448   51456       +8     
=========================================
+ Hits        43576   43584       +8     
  Misses       7872    7872
Impacted Files Coverage Δ
Bio/SeqUtils/MeltingTemp.py 82.14% <100%> (+0.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c6a2c2...16f57d4. Read the comment docs.

@MarkusPiotrowski MarkusPiotrowski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why there is no easy way to switch this variable expansion off in autodoc for function headers.
But given that this is the only reasonable way to improve the readability of the API documentation, I agree.

@peterjc

peterjc commented Aug 27, 2019

Copy link
Copy Markdown
Member Author

There's a flake8 plugin to look for mutable defaults (but only checks for calls, lists, sets, dict), so I don't think it would have caught this:

https://github.com/ebeweber/flake8-mutable

Likewise pylint has dangerous-default-value (W0102), for lists or dicts only:

http://pylint.pycqa.org/en/latest/technical_reference/features.html

@peterjc
peterjc merged commit 09ac76c into biopython:master Aug 27, 2019
@peterjc
peterjc deleted the melting_default branch August 27, 2019 12:17
@peterjc

peterjc commented Aug 27, 2019

Copy link
Copy Markdown
Member Author

Applied, thank you Markus.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants