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

feat: implement python package fetcher #407

Merged
merged 14 commits into from Oct 27, 2021
Merged

feat: implement python package fetcher #407

merged 14 commits into from Oct 27, 2021

Conversation

isac322
Copy link
Contributor

@isac322 isac322 commented Oct 11, 2021

Fixes #202

Proposed changes

  • fetching style file from installed python package

As I described in related issue, it would be more consistent if nitpick can fetch style file from installed python package.
I created custom URL scheme: py://package_name/path/to/resource and read resource file using importlib.resources which is recommended in modern Python.

Checklist

  • Read the contribution guidelines
  • Run make locally before pushing commits
  • Add tests for the relevant parts:
    • API
    • CLI
    • flake8 plugin (normal mode)
    • flake8 plugin (offline mode)
  • Write documentation when there's a new API or functionality

.pre-commit-config.yaml Outdated Show resolved Hide resolved
docs/cli.rst Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
@isac322
Copy link
Contributor Author

isac322 commented Oct 16, 2021

@andreoliwa CI failed on file that I didn't modified. Please help this.

@andreoliwa
Copy link
Owner

@isac322 Thanks a lot for this pull request! I still didn't have time to check it in detail, but hang in there. 😉

About the error, I guess that pylint might have been upgraded (I use Renovate Bot) and it might have a new check failing with existing code:

lint run-test: commands[1] | pylint src/
  ************* Module src.nitpick.formats
  src/nitpick/formats.py:216:27: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
  src/nitpick/formats.py:248:27: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
  src/nitpick/formats.py:289:27: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
  ************* Module src.nitpick.style.fetchers.file
  src/nitpick/style/fetchers/file.py:17:15: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)

I will fix it in another commit, then you can rebase or merge the commit in your branch.

@andreoliwa
Copy link
Owner

I fixed the build. Please merge the develop branch or cherry-pick these 2 commits:

I had to upgrade ConfigUpdater to fix a breaking change (pyscaffold/configupdater#39 (comment)).
I ended up upgrading all packages, so you might have a conflict on poetry.lock. 😬

@isac322
Copy link
Contributor Author

isac322 commented Oct 25, 2021

@andreoliwa Conflict resolved!

@coveralls
Copy link

coveralls commented Oct 25, 2021

Pull Request Test Coverage Report for Build 1390202246

  • 32 of 34 (94.12%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 96.433%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/nitpick/style/fetchers/pypackage.py 30 32 93.75%
Totals Coverage Status
Change from base Build 1381679532: -0.03%
Covered Lines: 1926
Relevant Lines: 1974

💛 - Coveralls

@andreoliwa andreoliwa self-requested a review October 25, 2021 15:31
Copy link
Owner

@andreoliwa andreoliwa left a comment

Choose a reason for hiding this comment

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

It looks good, thanks for this addition. 🙏🏻

I just left a few questions.
After having the answers, I can add some documentation on configuration.rst and approve this pull request.

pyproject.toml Show resolved Hide resolved
src/nitpick/style/fetchers/pypackage.py Outdated Show resolved Hide resolved
src/nitpick/style/fetchers/pypackage.py Show resolved Hide resolved
isac322 and others added 2 commits October 26, 2021 23:52
Co-authored-by: W. Augusto Andreoli <andreoliwa@gmail.com>
Copy link
Owner

@andreoliwa andreoliwa left a comment

Choose a reason for hiding this comment

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

Thanks!
I'll add some docs about this feature, and we're good to go.

src/nitpick/style/fetchers/pypackage.py Show resolved Hide resolved
@andreoliwa andreoliwa merged commit 0a3c95d into andreoliwa:develop Oct 27, 2021
github-actions bot pushed a commit that referenced this pull request Oct 27, 2021
# [0.28.0](v0.27.0...v0.28.0) (2021-10-27)

### Bug Fixes

* remove() has changed to detach() on the ConfigUpdater API ([93c6c52](93c6c52))

### Features

* read style from Python package (thanks to [@isac322](https://github.com/isac322)) ([#407](#407)) ([0a3c95d](0a3c95d))
@github-actions
Copy link

🎉 This PR is included in version 0.28.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Feature/fix is released label Oct 27, 2021
@isac322 isac322 deleted the style_from_py_package branch October 27, 2021 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Feature/fix is released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get style file from python package
3 participants