Skip to content

make sure citations file closed after read - #1620

Merged
valentinsulzer merged 4 commits into
pybamm-team:developfrom
chuckliu1979:develop
Aug 26, 2021
Merged

make sure citations file closed after read#1620
valentinsulzer merged 4 commits into
pybamm-team:developfrom
chuckliu1979:develop

Conversation

@chuckliu1979

Copy link
Copy Markdown

Description

citations file not closed in pybamm.citations.Citations.read_citations which causes pytest failed if import pybamm:

_pytest/unraisableexception.py:78: in unraisable_exception_runtest_hook
warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E pytest.PytestUnraisableExceptionWarning: Exception ignored in: <_io.FileIO [closed]>
E
E Traceback (most recent call last):
E File "pybamm/citations.py", line 45, in read_citations
E for line in open(citations_file):
E ResourceWarning: unclosed file <_io.TextIOWrapper name='pybamm/CITATIONS.txt' mode='r' encoding='UTF-8'>

Fixes # (issue)

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov

codecov Bot commented Aug 25, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1620 (1696630) into develop (b12c3ee) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 1696630 differs from pull request most recent head 1e617db. Consider uploading reports for the commit 1e617db to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1620      +/-   ##
===========================================
- Coverage    97.99%   97.99%   -0.01%     
===========================================
  Files          328      327       -1     
  Lines        18676    18666      -10     
===========================================
- Hits         18301    18291      -10     
  Misses         375      375              
Impacted Files Coverage Δ
pybamm/citations.py 100.00% <100.00%> (ø)
pybamm/models/submodels/porosity/__init__.py 100.00% <0.00%> (ø)
pybamm/models/submodels/interface/sei/base_sei.py 100.00% <0.00%> (ø)
...els/submodels/porosity/reaction_driven_porosity.py 100.00% <0.00%> (ø)
...ubmodels/interface/lithium_plating/base_plating.py 100.00% <0.00%> (ø)
...submodels/porosity/reaction_driven_porosity_ode.py

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 b12c3ee...1e617db. Read the comment docs.

@brosaplanella brosaplanella left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, thanks @chuckliu1979! Before merging, can you add a line to CHANGELOG under the bug fixes section explaining what you did?

@brosaplanella

Copy link
Copy Markdown
Member

@all-contributors please add @chuckliu1979 for bug report and code

@allcontributors

Copy link
Copy Markdown
Contributor

@brosaplanella

I've put up a pull request to add @chuckliu1979! 🎉

@chuckliu1979

Copy link
Copy Markdown
Author

Looks good, thanks @chuckliu1979! Before merging, can you add a line to CHANGELOG under the bug fixes section explaining what you did?

sure. new commit added

@valentinsulzer
valentinsulzer merged commit 01ec443 into pybamm-team:develop Aug 26, 2021
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.

3 participants