Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unclosed pyproject.toml leads to a ResourceWarning #469

Closed
2 tasks done
lociii opened this issue Nov 28, 2022 · 3 comments
Closed
2 tasks done

[BUG] Unclosed pyproject.toml leads to a ResourceWarning #469

lociii opened this issue Nov 28, 2022 · 3 comments
Labels

Comments

@lociii
Copy link

lociii commented Nov 28, 2022

Sorry for "abusing" the feature request template but there is non that fits bugs related to the library implementation, not the formatter or linter.

Library bug report

$ djlint template.html 
/home/app/venv/lib/python3.10/site-packages/djlint/settings.py:119: ResourceWarning: unclosed file <_io.BufferedReader name='/app/pyproject.toml'>
content = tomllib.load(pyproject_file.open("rb"))

The current way of loading the pyproject.tml file does not properly close the file descriptor.
See https://github.com/Riverside-Healthcare/djLint/blob/master/src/djlint/settings.py#L119

Therefore

with open(pyproject_file. "rb") as fp:
    content = tomllib.load(fp)

should solve the issue and not trigger a warning anymore.
I'd be happy to supply a merge request if the solution is accepted.

@christopherpickering
Copy link
Contributor

Nice catch! Since its a path object, maybe we can do .read_bytes() to keep it inline?

christopherpickering pushed a commit that referenced this issue Dec 15, 2022
## [1.19.8](v1.19.7...v1.19.8) (2022-12-15)

### Bug Fixes

* **attributes:** fixed outer quotes being stripped from attribute values ([dff02dc](dff02dc)), closes [#471](#471)
* **settings:** fixed pyproject loader ([5890161](5890161)), closes [#469](#469)
* **textarea:** fixed textarea attribute formatting ([e7c904e](e7c904e)), closes [#486](#486)
@christopherpickering
Copy link
Contributor

🎉 This issue has been resolved in version 1.19.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lociii
Copy link
Author

lociii commented Dec 18, 2022

Awesome. Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants