Giter Club home page Giter Club logo

nitpick's Introduction

Nitpick

PyPI Supported Python versions GitHub Actions Python Workflow Documentation Status Coveralls Maintainability Test Coverage pre-commit pre-commit.ci status Project License Code style: black Renovate semantic-release FOSSA Status

Command-line tool and flake8 plugin to enforce the same settings across multiple language-independent projects.

Useful if you maintain multiple projects and are tired of copying/pasting the same INI/TOML/YAML/JSON keys and values over and over, in all of them.

The CLI now has a nitpick fix command that modifies configuration files directly (pretty much like black and isort do with Python files). See the CLI docs for more info.

Many more features are planned for the future, check the roadmap.

The style file

A "Nitpick code style" is a TOML file with the settings that should be present in config files from other tools.

Example of a style:

["pyproject.toml".tool.black]
line-length = 120

["pyproject.toml".tool.poetry.dev-dependencies]
pylint = "*"

["setup.cfg".flake8]
ignore = "D107,D202,D203,D401"
max-line-length = 120
inline-quotes = "double"

["setup.cfg".isort]
line_length = 120
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
combine_as_imports = true

This style will assert that:

Supported file types

These are the file types currently handled by Nitpick.

  • Some files are only being checked and have to be modified manually;
  • Some files can already be fixed automatically (with the nitpick fix command);
  • Others are still under construction; the ticket numbers are shown in the table (upvote the ticket with ๐Ÿ‘๐Ÿป if you would like to prioritise development).

Implemented

File type nitpick check nitpick fix
Any INI file โœ… โœ…
Any JSON file โœ… โœ…
Any plain text file โœ… โŒ
Any TOML file โœ… โœ…
Any YAML file โœ… โœ…
.editorconfig โœ… โœ…
.pylintrc โœ… โœ…
setup.cfg โœ… โœ…

Planned

File type nitpick check nitpick fix
Any Markdown file #280 ๐Ÿšง โ“
Any Terraform file #318 ๐Ÿšง โ“
Dockerfile #272 ๐Ÿšง #272 ๐Ÿšง
.dockerignore #8 ๐Ÿšง #8 ๐Ÿšง
.gitignore #8 ๐Ÿšง #8 ๐Ÿšง
Jenkinsfile #278 ๐Ÿšง โ“
Makefile #277 ๐Ÿšง โ“

Style Library (Presets)

Nitpick has a builtin library of style presets, shipped as Python resources.

This library contains building blocks for your your custom style. Just choose styles from the table below and create your own style, like LEGO.

Read how to:

any

Style URL Description
py://nitpick/resources/any/codeclimate CodeClimate
py://nitpick/resources/any/commitizen Commitizen (Python)
py://nitpick/resources/any/commitlint commitlint
py://nitpick/resources/any/editorconfig EditorConfig
py://nitpick/resources/any/git-legal Git.legal - CodeClimate Community Edition
py://nitpick/resources/any/pre-commit-hooks pre-commit hooks for any project
py://nitpick/resources/any/prettier Prettier

javascript

Style URL Description
py://nitpick/resources/javascript/package-json package.json

kotlin

Style URL Description
py://nitpick/resources/kotlin/ktlint ktlint

markdown

Style URL Description
py://nitpick/resources/markdown/markdownlint Markdown lint

presets

Style URL Description
py://nitpick/resources/presets/nitpick Default style file for Nitpick

proto

Style URL Description
py://nitpick/resources/proto/protolint protolint (Protobuf linter)

python

Style URL Description
py://nitpick/resources/python/310 Python 3.10
py://nitpick/resources/python/311 Python 3.11
py://nitpick/resources/python/312 Python 3.12
py://nitpick/resources/python/38 Python 3.8
py://nitpick/resources/python/39 Python 3.9
py://nitpick/resources/python/absent Files that should not exist
py://nitpick/resources/python/autoflake autoflake
py://nitpick/resources/python/bandit Bandit
py://nitpick/resources/python/black Black
py://nitpick/resources/python/flake8 Flake8
py://nitpick/resources/python/github-workflow GitHub Workflow for Python
py://nitpick/resources/python/ipython IPython
py://nitpick/resources/python/isort isort
py://nitpick/resources/python/mypy Mypy
py://nitpick/resources/python/poetry-editable Poetry (editable projects; PEP 600 support)
py://nitpick/resources/python/poetry-venv Poetry (virtualenv in project)
py://nitpick/resources/python/poetry Poetry
py://nitpick/resources/python/pre-commit-hooks pre-commit hooks for Python projects
py://nitpick/resources/python/pylint Pylint
py://nitpick/resources/python/radon Radon
py://nitpick/resources/python/readthedocs Read the Docs
py://nitpick/resources/python/sonar-python SonarQube Python plugin
py://nitpick/resources/python/tox tox

shell

Style URL Description
py://nitpick/resources/shell/bashate bashate (code style for Bash)
py://nitpick/resources/shell/shellcheck ShellCheck (static analysis for shell scripts)
py://nitpick/resources/shell/shfmt shfmt (shell script formatter)

toml

Style URL Description
py://nitpick/resources/toml/toml-sort TOML sort

Quickstart

Install

Install in an isolated global environment with pipx:

# Latest PyPI release
pipx install nitpick

# Development branch from GitHub
pipx install git+https://github.com/andreoliwa/nitpick

On macOS/Linux, install with Homebrew:

# Latest PyPI release
brew install andreoliwa/formulae/nitpick

# Development branch from GitHub
brew install andreoliwa/formulae/nitpick --HEAD

On Arch Linux, install with yay:

yay -Syu nitpick

Add to your project with Poetry:

poetry add --dev nitpick

Or install it with pip:

pip install -U nitpick

Run

Nitpick will fail if no style is explicitly configured. Run this command to download and use the opinionated default style file:

nitpick init

You can use it as a template to `configure-your-own-style`_.

To fix and modify your files directly:

nitpick fix

To check for errors only:

nitpick check

Nitpick is also a flake8 plugin, so you can run this on a project with at least one Python (.py) file:

flake8 .

Run as a pre-commit hook

If you use pre-commit on your project, add this to the .pre-commit-config.yaml in your repository:

repos:
  - repo: https://github.com/andreoliwa/nitpick
    rev: v0.35.0
    hooks:
      - id: nitpick

There are 3 available hook IDs:

  • nitpick and nitpick-fix both run the nitpick fix command;
  • nitpick-check runs nitpick check.

If you want to run Nitpick as a flake8 plugin instead:

repos:
  - repo: https://github.com/PyCQA/flake8
    rev: 4.0.1
    hooks:
      - id: flake8
        additional_dependencies: [nitpick]

Run as a MegaLinter plugin

If you use MegaLinter you can run Nitpick as a plugin. Add the following two entries to your .mega-linter.yml configuration file:

PLUGINS:
  - https://raw.githubusercontent.com/andreoliwa/nitpick/v0.35.0/mega-linter-plugin-nitpick/nitpick.megalinter-descriptor.yml
ENABLE_LINTERS:
  - NITPICK

More information

Nitpick is being used by projects such as:

For more details on styles and which configuration files are currently supported, see the full documentation.

Contributing

Your help is very much appreciated.

There are many possibilities for new features in this project, and not enough time or hands to work on them.

If you want to contribute with the project, set up your development environment following the steps on the contribution guidelines and send your pull request.

nitpick's People

Contributors

andreoliwa avatar danygielow avatar dependabot-preview[bot] avatar dependabot[bot] avatar fossabot avatar isac322 avatar jaysonsantos avatar michael-k avatar mjpieters avatar mrijken avatar pre-commit-ci[bot] avatar pyup-bot avatar renovate-bot avatar renovate[bot] avatar semantic-release-bot avatar tfh-cri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nitpick's Issues

Check .travis.yml

Expected Behavior

Check Travis CI configuration on .travis.yml.
Warn about missing and different keys.

Current Behavior

The file is not being checked.

Possible Solution

# To reuse common YAML code
class YamlFile(BaseFile):
    pass
class TravisYml(YamlFile):
    pass
# Also change the parent class for pre-commit
class PreCommitFile(YamlFile):
    pass

Context

E.g.: Travis config should always contain some data like this:

script:
  - safety check

install:
  - pip install safety

Validate style files using Marshmallow schemas

Expected Behavior

Validate style files against schemas, to warn developers about wrong or extra/unnecessary data in the style.
This should help to detect configuration errors like #67.

Current Behavior

Errors are raised when the style is invalid.

Possible Solution

Use https://github.com/marshmallow-code/marshmallow/ schemas for:

  • The [tool.nitpick] section of pyproject.toml;
  • Each one of the BaseFile inherited classes.

This validation should be the first thing executed, right after merging the style files into one.

Context

For more information, see the CONTRIBUTING guide.

nitpick fails to catch mismatching semantic-release (JS) versions

Expected Behavior

nitpick should pick-up on mismatching dependency versions in package.json vs. its style definition.

Current Behavior

nitpick does not report a problem.
nitpick displays a warning instead (though it is silenced by pre-commit unless using the -v flag):

WARNING:nitpick.formats:Unexpected case key=['devDependencies.semantic-release'] raw_expected=^15.13.0

Possible Solution

(I did not dig too deep in the source for this.)

Steps to Reproduce

A very minimal example can be seen in the gist b8c9888c.

  1. poetry install
  2. poetry run flake8

Context

We want to bump semantic-release in our projects. Since we are enforcing consistency across projects with nitpick, we are also using it to pin this JS tool (cf. example).

Your Environment

  • nitpick version used: 0.22.1

  • Python version: 3.7.5

  • Operating System and version: GNU/Linux 4.19.0-9-amd64 in Debian Buster

  • Link to your project:

  • Run the following commands and paste the output:

    which python3
    python3 -V
    pip freeze
    cat $(which flake8)
    /home/borjan/.cache/pypoetry/virtualenvs/test-gclK-b8T-py3.7/bin/python3
    Python 3.7.5
    attrs==19.3.0
    certifi==2020.4.5.1
    chardet==3.0.4
    click==7.1.2
    dictdiffer==0.8.1
    entrypoints==0.3
    flake8==3.7.9
    idna==2.9
    jmespath==0.9.5
    marshmallow==3.6.0
    marshmallow-polyfield==5.9
    mccabe==0.6.1
    nitpick==0.22.1
    pkg-resources==0.0.0
    pycodestyle==2.5.0
    pyflakes==2.1.1
    python-slugify==4.0.0
    requests==2.23.0
    ruamel.yaml==0.16.10
    ruamel.yaml.clib==0.2.0
    sortedcontainers==2.1.0
    text-unidecode==1.3
    toml==0.10.0
    urllib3==1.25.9
    #!/home/borjan/.cache/pypoetry/virtualenvs/test-gclK-b8T-py3.7/bin/python
    # -*- coding: utf-8 -*-
    import re
    import sys
    
    from flake8.main.cli import main
    
    if __name__ == '__main__':
        sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
        sys.exit(main())
    

Pre-commit: check if the hooks are in the expected order

Expected Behavior

Check if the order of the hooks on .pre-commit-config.yaml is the same as defined on the style file.

Current Behavior

Right now, only the presence of hooks is checked.

Possible Solution

No idea.

Context

You might want to execute faster hooks like black and isort before flake8 and mypy, and even leave pylint at last.

Add multiline option to text plugin

Currently having to add multiple lines for the same file is a bit cumbersome:

[["requirements/test.txt".contains]]
line = "black"
[["requirements/test.txt".contains]]
line = "flake8"
[["requirements/test.txt".contains]]
line = "flake8-bandit"

Expected Behavior

I Would like to see the following option:

[["requirements/test.txt".contains]]
lines = ["black", "flake8", "flake8-bandit"]

This would be equivalent to the above lines

Docs

BTW: something to put in the documentation about this:
EDIT: I see this is not supported yet and the plugin assumes a single line. So add this to the desired feature:

toml supports multiline strings so this is also a valid but not obvious usecase:

[["LICENSE".contains]]
line = """                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/
...
"""

I would expect a multiline string to also enforce the internal order unlike the lines example

Check arbitrary (supported) files

Expected Behavior

Similar to the "[nitpick.JSONFile]" section, arbitrary TOML, YAML, etc. files can have content enforcement.

Current Behavior

With the notable exception of JSON files, there is a definitive list of supported files that one has to abide by.
Even though the formats are parsed and handled by nitpick, the files are not on the whitelist.

Possible Solution

Rely on the filename extension to apply the format checker instead of using a whitelist.

Context

We would like to enforce new configurations with nitpick:

Prettier can also parse a JSON configuration, but we would ideally not rewrite the configuration and open the door for more of our YAML files.

Incorrect reported line

Expected Behavior

ยป flake8 .

./tests/test_version.py

  0:1      NIP001 File mypy.toml has an incorrect style. Invalid TOML:
TomlDecodeError: This float doesn't have a leading digit (line 2 column 1 char 19)

Current Behavior

ยป flake8 .

./tests/test_version.py

  1:1      NIP001 File mypy.toml has an incorrect style. Invalid TOML:
TomlDecodeError: This float doesn't have a leading digit (line 2 column 1 char 19)
  # -*- coding: utf-8 -*-
  ^

When you report violations on line 0 they are not bound to any source line.
When you report violation on line 1 they are bound to the first line and since this moment --show-source works incorrectly and report this part:

# -*- coding: utf-8 -*-
  ^

(This is my first line from ./tests/test_version.py)

I would also like to highlight that ./tests/test_version.py does not hav anything to do with the reported violation. It might create some interesting situations.

I know that flake8 has quite a strange violation reporting API, but can we consider reporting this violation on files like nitpick-style.toml or similar?

Unexpected behavior (or misunderstanding) of nitpick quickstart steps

Not sure i misunderstood the out-of-the-box behavior of nitpick or there is a bug. I except that nitpick should report missing files when ran inside an empty project folder, and the default style file should be downloaded

Expected Behavior

In a folder, with poetry, pyproject.toml, and venv setup, install nitpick and run flake8:

  • Default style file is downloaded into folder (nitpick-style.toml)
  • "Missing" files are reported by flake8 command (e.g missing toml files, setup.cfg)

Current Behavior

In an empty folder, while running in a venv, install nitpick and run flake8:

  • nothing happens. You get another command prompt

Possible Solution

Not sure if this is the correct behavior or my misinterpretation of nitpick's functionality/docs

Steps to Reproduce

  • mkdir test && cd test
  • poetry init
  • poetry add nitpick
  • poetry shell
  • flake8

Your Environment

  • nitpick version used:0.21.3

  • Python version: 3.7

  • Operating System and version: macos

  • Run the following commands and paste the output:
    Python 3.7.3
    attrs==19.3.0
    certifi==2019.11.28
    chardet==3.0.4
    Click==7.0
    dictdiffer==0.8.1
    entrypoints==0.3
    flake8==3.7.9
    idna==2.8
    jmespath==0.9.4
    marshmallow==3.4.0
    marshmallow-polyfield==5.8
    mccabe==0.6.1
    nitpick==0.21.3
    pycodestyle==2.5.0
    pyflakes==2.1.1
    python-slugify==4.0.0
    requests==2.22.0
    ruamel.yaml==0.16.10
    ruamel.yaml.clib==0.2.0
    sortedcontainers==2.1.0
    text-unidecode==1.3
    toml==0.10.0
    urllib3==1.25.8
    #~/.asdf/installs/python/3.7.3/bin/python3.7

-- coding: utf-8 --

import re
import sys

from flake8.main.cli import main

if name == 'main':
sys.argv[0] = re.sub(r'(-script.pyw?|.exe)?$', '', sys.argv[0])
sys.exit(main())

Conflict with [email protected]

Expected Behavior

Can be install [email protected] with [email protected]

Current Behavior

[SolverProblemError]
Because no versions of nitpick match >0.22.2,<0.23.0
 and nitpick (0.22.2) depends on toml (<0.10.1), nitpick (>=0.22.2,<0.23.0) requires toml (<0.10.1).
And because black (20.8b1) depends on toml (>=0.10.1)
 and no versions of black match >20.8b1,<21.0, nitpick (>=0.22.2,<0.23.0) is incompatible with black (>=20.8b1,<21.0).
So, because buzzvil-python-styleguide depends on both black (^20.8b1) and nitpick (^0.22.2), version solving failed.

Possible Solution

Upgrade minimum version of toml

Steps to Reproduce

  1. poetry add --dev nitpick
  2. poetry add --dev black

Your Environment

  • nitpick version used: 0.22.2

  • Python version: 3.8.5

  • Operating System and version: macOS 10.15.6

  • Link to your project: local project

  • Run the following commands and paste the output:

/usr/local/bin/python3
Python 3.8.5
aiohttp==3.6.2
async-timeout==3.0.1
attrs==19.3.0
Automat==20.2.0
cffi==1.14.0
chardet==3.0.4
constantly==15.1.0
cryptography==2.9.2
deluge==2.0.3
hyperlink==19.0.0
idna==2.9
incremental==17.5.0
Mako==1.1.3
MarkupSafe==1.1.1
multidict==4.7.6
Pillow==7.2.0
protobuf==3.13.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycairo==1.19.1
pycparser==2.20
PyGObject==3.36.1
PyHamcrest==2.0.2
pyOpenSSL==19.1.0
pyxdg==0.26
rencode==1.0.6
service-identity==18.1.0
setproctitle==1.1.10
six==1.15.0
Twisted==20.3.0
yarl==1.4.2
zope.interface==5.1.0

#!/usr/local/opt/python/bin/python3.7
# -*- coding: utf-8 -*-
import re
import sys
from flake8.main.cli import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Using the text plugin to check yaml files does not work and results in an error

Expected Behavior

I tried the text plugin to check a yaml file using this style

[[".gitlab-ci.yml".contains]]
line = "    - mypy -p ims --junit-xml report-mypy.xml"
[[".gitlab-ci.yml".contains]]
line = "    - apache-license-check --copyright \"2019-2020 SURF\" ims"
[[".gitlab-ci.yml".contains]]
line = "    - flake8 --tee --output-file flake8.txt; exit_code=$?; flake8_junit flake8.txt report-flake8.xml"
[[".gitlab-ci.yml".contains]]
line = "    - if [ $exit_code -ne 0 ]; then exit 1; fi;"
[[".gitlab-ci.yml".contains]]
line = "    - isort -c ims"
[[".gitlab-ci.yml".contains]]
line = "    - black --check ."
[[".gitlab-ci.yml".contains]]
line = "    - pytest --cov=ims --cov-branch --junitxml=report-pytest-unit.xml --cov-fail-under="

Current Behavior

It fails because the text plugin only accepts plain-text files and thus it gives an error about files not being configured correctly

Expected Behavior

I expect the text plugin to always work (maybe even with binary files) since it provides an escape hatch for unsupported formats or weird files where inspect might do the wrong thing

Your Environment

  • nitpick version used: Latest

  • Python version: 3.8

  • Operating System and version: Ubuntu 20.04

Readme: enforce and check a README file (either .md or .rst)

Expected Behavior

Any Python project should always have a README.md or README.rst file.
And they might need certain content in it.

If the style file contains values for both files, raise a flake8 error as well ("Your style file contains rules for README.md and README.rst. Use only one of them").

Current Behavior

Those files don't have a file checker for their content.

Possible Solution

# Create parent classes to set the precedent to check even other .rst or .md files
class MarkdownFile(BaseFile):
    pass
class RestructuredTextFile(BaseFile):
    pass
class ReadmeMd(MarkdownFile):
    pass
class ReadmeRst(RestructuredTextFile):
    pass

Context

Real world examples:

  • The readme should have a PyPI and a Travis CI badge for a library project;
  • All Python projects should have a black badge.

Support caching styles

Expected Behavior

When referring to remote (possibly immutable) styles, a caching mechanism would be really helpful to 1) lower the resolution time and 2) allow for offline evaluation.

Note: this is different from an "offline mode" as requested in #129 in the sense that it is orthogonal. It does not matter if you are connected or not, the cache gets hit first and the resolution stops there if the cache is not invalidated. nitpick is then run normally.

Current Behavior

The remote styles are downloaded every time nitpick is invoked.

Possible Solution

A new key cache defined in the tool configuration:

  • In the [tool.nitpick] section in pyproject.toml;
  • In the [nitpick] section in nitpick-style.toml, when pyproject.toml is absent.

The cache key would support the following values:

  • never: Never cache, the style file(s) are always looked-up.
  • forever: Once the style(s) are cached, they never expire.
  • an integer n > 0: the cache expires after n seconds (or minutes, or hours, or days).

The cached styles would live in the cache directory, keyed by the hash of their URI.
Individual styles would not be cached, only the resulting generated style (that is currently living in the cache directory by the way).
Keying by URI allows to handle immutable styles painlessly.

Context

We are referring styles from our public GitHub repo directly (through git sha-1 for now, later through releases or signed tags).
The point is that we do not want to rely on local checkouts (e.g. for CI) and pointing to a stable URI that features an immutable content seems like a better idea.

The problem with GitHub raw data is that even though the content is immutable by definition, the HTTP headers are not really helping: they return a TTL of 5 minutes.

Caching based on the HTTP headers would be an improvement over no caching, but in the use-case I described, far from optimal. Manually setting the cache to never expire would be the best solution.

Final thoughts

Considering caching is a hard problem, I suppose I oversaw many cases. I am particularly wary about caching for a finite amount of time. I think that part would be the hardest one, also because of the platform support that might be missing.

nitpick does not work with [email protected]

After my update to [email protected] nitpick stoped working.

(.venv) ~/Documents/github/returns  master โœ—                                       โœš 
ยป poetry update
Updating dependencies
Resolving dependencies... (10.4s)

Writing lock file


Package operations: 0 installs, 12 updates, 1 removal

  - Updating smmap (3.0.2 -> 3.0.4)
  - Updating gitdb (4.0.4 -> 4.0.5)
  - Updating pycodestyle (2.5.0 -> 2.6.0)
  - Updating pyflakes (2.1.1 -> 2.2.0)
  - Updating flake8 (3.7.9 -> 3.8.1)
  - Updating gitpython (3.1.1 -> 3.1.2)
  - Updating pytz (2019.3 -> 2020.1)
  - Updating toml (0.10.0 -> 0.10.1)
  - Updating marshmallow (3.5.1 -> 3.6.0)
  - Updating click (7.1.1 -> 7.1.2)
  - Updating darglint (1.2.3 -> 1.3.0)
  - Updating jmespath (0.9.5 -> 0.10.0)
  - Removing entrypoints (0.3)

(.venv) ~/Documents/github/returns  master โœ—                                       โœš 
ยป flake8 .
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/sobolev/.pyenv/versions/3.7.7/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/Users/sobolev/.pyenv/versions/3.7.7/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/checker.py", line 664, in _run_checks
    return checker.run_checks()
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/checker.py", line 505, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/nitpick/plugin.py", line 52, in run
    Nitpick.current_app().config.merge_styles(), self.check_files(True), self.check_files(False)
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/nitpick/config.py", line 65, in merge_styles
    style.find_initial_styles(configured_styles)
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/nitpick/style.py", line 63, in find_initial_styles
    self.include_multiple_styles(chosen_styles)
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/nitpick/style.py", line 99, in include_multiple_styles
    self.include_multiple_styles(sub_styles)
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/nitpick/style.py", line 84, in include_multiple_styles
    toml_dict = toml.as_data
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/nitpick/formats.py", line 125, in as_data
    self.load()
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/nitpick/formats.py", line 226, in load
    self._reformatted = toml.dumps(self._data)
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/toml/encoder.py", line 67, in dumps
    raise ValueError("Circular reference detected")
ValueError: Circular reference detected
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/sobolev/Documents/github/returns/.venv/bin/flake8", line 10, in <module>
    sys.exit(main())
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 360, in run
    self._run(argv)
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 348, in _run
    self.run_checks()
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/main/application.py", line 262, in run_checks
    self.file_checker_manager.run()
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/checker.py", line 332, in run
    self.run_parallel()
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/flake8/checker.py", line 296, in run_parallel
    for ret in pool_map:
  File "/Users/sobolev/.pyenv/versions/3.7.7/lib/python3.7/multiprocessing/pool.py", line 354, in <genexpr>
    return (item for chunk in result for item in chunk)
  File "/Users/sobolev/.pyenv/versions/3.7.7/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
ValueError: Circular reference detected

Expected Behavior

I would expect it to work as regular.
By the way, I don' have any issues to report in my project.

Steps to Reproduce

  1. Clone https://github.com/dry-python/returns, commit ref: dry-python/returns@bfd1ba4
  2. Run poetry update
  3. Run flake8 .

Your Environment

  • nitpick version used: 0.22.1

  • Python version: 3.7.7

  • Operating System and version: macos

  • Link to your project: https://github.com/dry-python/returns

  • Run the following commands and paste the output:

    which python3
    python3 -V
    pip freeze
    cat $(which flake8)
/Users/sobolev/Documents/github/returns/.venv/bin/python3
Python 3.7.7
WARNING: Could not find setup.py for directory /Users/sobolev/Documents/github/returns (tried all parent directories)
alabaster==0.7.12
anyio==1.3.0
astor==0.8.1
async-generator==1.10
attrs==19.3.0
Babel==2.8.0
bandit==1.6.2
certifi==2020.4.5.1
chardet==3.0.4
click==7.1.2
coverage==5.1
curio==1.2
darglint==1.3.0
decorator==4.4.2
dictdiffer==0.8.1
doc8==0.8.0
docutils==0.16
dparse==0.5.1
eradicate==1.0
flake8==3.8.1
flake8-bandit==2.1.2
flake8-broken-line==0.2.0
flake8-bugbear==19.8.0
flake8-commas==2.0.0
flake8-comprehensions==3.2.2
flake8-debugger==3.2.1
flake8-docstrings==1.5.0
flake8-eradicate==0.3.0
flake8-isort==2.9.1
flake8-plugin-utils==1.3.0
flake8-polyfill==1.0.2
flake8-pyi==20.5.0
flake8-pytest-style==1.1.1
flake8-quotes==2.1.2
flake8-rst-docstrings==0.0.12
flake8-string-format==0.2.3
gitdb==4.0.5
GitPython==3.1.2
idna==2.9
imagesize==1.2.0
importlib-metadata==1.6.0
isort==4.3.21
Jinja2==2.11.2
jmespath==0.10.0
m2r==0.2.1
MarkupSafe==1.1.1
marshmallow==3.6.0
marshmallow-polyfield==5.9
mccabe==0.6.1
mistune==0.8.4
more-itertools==8.2.0
mypy==0.770
mypy-extensions==0.4.3
nitpick==0.22.1
outcome==1.0.1
packaging==20.3
pbr==5.4.5
pep8-naming==0.9.1
pluggy==0.13.1
py==1.8.1
pycodestyle==2.6.0
pydocstyle==5.0.2
pyflakes==2.2.0
Pygments==2.6.1
pyparsing==2.4.7
pytest==5.4.2
pytest-cov==2.8.1
pytest-mypy-plugins==1.3.0
pytest-randomly==3.3.1
pytest-subtests==0.3.0
python-slugify==4.0.0
pytz==2020.1
PyYAML==5.3.1
requests==2.23.0
restructuredtext-lint==1.3.0
-e git+https://github.com/dry-python/returns.git@bfd1ba4a7f34065cb05afe11836c4d7ee31691c1#egg=returns
ruamel.yaml==0.16.10
ruamel.yaml.clib==0.2.0
safety==1.9.0
six==1.14.0
smmap==3.0.4
sniffio==1.1.0
snowballstemmer==2.0.0
sortedcontainers==2.1.0
Sphinx==2.4.4
sphinx-autodoc-typehints==1.10.3
sphinx-typlog-theme==0.8.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-mermaid==0.4.0
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
stevedore==1.32.0
testfixtures==6.14.1
text-unidecode==1.3
toml==0.10.1
tomlkit==0.6.0
trio==0.14.0
typed-ast==1.4.1
typing-extensions==3.7.4.2
urllib3==1.25.9
wcwidth==0.1.9
wemake-python-styleguide==0.14.0
zipp==3.1.0
#!/Users/sobolev/Documents/github/returns/.venv/bin/python
# -*- coding: utf-8 -*-
import re
import sys

from flake8.main.cli import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Can't download default style with nitpick

Expected Behavior

I expect nitpick to download default style file.

Current Behavior

I get Requests exception about invalid url.

Traceback (most recent call last):
  File "C:\Users\Sleip\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Sleip\AppData\Local\Programs\Python\Python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Sleip\Desktop\Git\poe_gems_requirements\venv\Scripts\flake8.exe\__main__.py", line 9, in <module>
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\flake8\main\cli.py", line 18, in main
    app.run(argv)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\flake8\main\application.py", line 393, in run
    self._run(argv)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\flake8\main\application.py", line 381, in _run
    self.run_checks()
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\flake8\main\application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\flake8\checker.py", line 331, in run
    self.run_serial()
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\flake8\checker.py", line 315, in run_serial
    checker.run_checks()
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\flake8\checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\flake8\checker.py", line 502, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\nitpick\plugin.py", line 50, in run
    Nitpick.current_app().config.merge_styles(), self.check_files(True), self.check_files(False)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\nitpick\config.py", line 65, in merge_styles
    style.find_initial_styles(configured_styles)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\nitpick\style.py", line 61, in find_initial_styles
    self.include_multiple_styles(chosen_styles)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\nitpick\style.py", line 97, in include_multiple_styles
    self.include_multiple_styles(sub_styles)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\nitpick\style.py", line 76, in include_multiple_styles
    style_path = self.get_style_path(style_uri)  # type: Optional[Path]
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\nitpick\style.py", line 105, in get_style_path
    style_path = self.fetch_style_from_url(clean_style_uri)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\nitpick\style.py", line 134, in fetch_style_from_url
    response = requests.get(new_url)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\requests\sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\requests\sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\requests\models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "c:\users\sleip\desktop\git\poe_gems_requirements\venv\lib\site-packages\requests\models.py", line 390, in prepare_url
    raise InvalidURL("Invalid URL %r: No host supplied" % url)
requests.exceptions.InvalidURL: Invalid URL 'https:///C:\\raw.githubusercontent.com\\andreoliwa\\nitpick\\v0.21.2\\styles\\python37.toml': No host supplied

Possible Solution

I think that problem is due to resolving domain_plus_url in style.fetch_style_from_url.
I don't understand why it's done for but it's looks like that problem can accure on Linux too.

>>> url = PosixPath('\\raw.githubusercontent.com\\andreoliwa\\nitpick\\v0.21.2\\styles\\python37')
>>> url.resolve()
PosixPath('/home/.anon-737a48732c124779a7a9e587/\\raw.githubusercontent.com\\andreoliwa\\nitpick\\v0.21.2\
\styles\\python37')

>>> url = WindowsPath('\\raw.githubusercontent.com\\andreoliwa\\nitpick\\v0.21.2\\styles\\python37')
>>> url.resolve()
WindowsPath('C:/raw.githubusercontent.com/andreoliwa/nitpick/v0.21.2/styles/python37')

Steps to Reproduce

  1. Install nitpick.
  2. Open project without any configs for flake8/nitpick.
  3. Run flake8 in project root.
  4. Get exception.

Your Environment

  • nitpick version used: 0.21.2

  • Python version: Python 3.7.4

  • Operating System and version: Windows 10

  • Run the following commands and paste the output:

    (venv) C:\Users\Sleip\Desktop\Git\poe_gems_requirements>where python
    C:\Users\Sleip\Desktop\Git\poe_gems_requirements\venv\Scripts\python.exe
    C:\Users\Sleip\AppData\Local\Programs\Python\Python37-32\python.exe
    
    (venv) C:\Users\Sleip\Desktop\Git\poe_gems_requirements>python -V
    Python 3.7.4
    
    (venv) C:\Users\Sleip\Desktop\Git\poe_gems_requirements>pip freeze
    altgraph==0.16.1
    astor==0.8.0
    atomicwrites==1.3.0
    attrs==19.2.0
    bandit==1.6.2
    certifi==2019.9.11
    chardet==3.0.4
    Click==7.0
    colorama==0.3.9
    dictdiffer==0.8.0
    docutils==0.15.2
    entrypoints==0.3
    eradicate==1.0
    flake8==3.7.8
    flake8-annotations-complexity==0.0.2
    flake8-bandit==2.1.2
    flake8-broken-line==0.1.1
    flake8-bugbear==19.8.0
    flake8-builtins==1.4.1
    flake8-coding==1.3.2
    flake8-commas==2.0.0
    flake8-comprehensions==2.2.0
    flake8-debugger==3.1.1
    flake8-docstrings==1.5.0
    flake8-eradicate==0.2.2
    flake8-executable==2.0.3
    flake8-isort==2.7.0
    flake8-logging-format==0.6.0
    flake8-pep3101==1.2.1
    flake8-polyfill==1.0.2
    flake8-print==3.1.1
    flake8-quotes==2.1.0
    flake8-rst-docstrings==0.0.11
    flake8-string-format==0.2.3
    future==0.18.0
    gitdb2==2.0.6
    GitPython==3.0.3
    idna==2.8
    importlib-metadata==0.23
    isort==4.3.21
    jmespath==0.9.4
    mando==0.6.4
    marshmallow==3.2.1
    marshmallow-polyfield==5.7
    mccabe==0.6.1
    more-itertools==7.2.0
    nitpick==0.21.2
    packaging==19.2
    pbr==5.4.3
    pefile==2019.4.18
    pep8-naming==0.8.2
    pluggy==0.13.0
    py==1.8.0
    pycodestyle==2.5.0
    pydocstyle==4.0.1
    pyflakes==2.1.1
    Pygments==2.4.2
    PyInstaller==3.5
    pyparsing==2.4.2
    pytest==5.2.1
    python-slugify==3.0.6
    pywin32-ctypes==0.2.0
    PyYAML==5.1.2
    radon==2.4.0
    requests==2.22.0
    restructuredtext-lint==1.3.0
    ruamel.yaml==0.16.5
    ruamel.yaml.clib==0.2.0
    six==1.12.0
    smmap2==2.0.5
    snowballstemmer==2.0.0
    sortedcontainers==2.1.0
    stevedore==1.31.0
    testfixtures==6.10.0
    text-unidecode==1.3
    toml==0.10.0
    typing-extensions==3.7.4
    urllib3==1.25.6
    wcwidth==0.1.7
    wemake-python-styleguide==0.12.5
    zipp==0.6.0

Error related to multiprocessing / ForkingPickler

After installing Nitpick 0.16.1 via pip install nitpick and then invoking flake8, the following error is returned:

> flake8
Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/pool.py", line 470, in _handle_results
    task = get()
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 251, in recv
    return _ForkingPickler.loads(buf.getbuffer())
TypeError: __init__() missing 2 required positional arguments: 'doc' and 'pos'

Uninstalling Nitpick resolves the problem and restores flake8 to its normal behavior.

Configuration in pyproject.toml

[tool.nitpick]
style = [
    "~/Projects/dotfiles/python/styles.toml",
]

Contents of ~/Projects/dotfiles/python/styles.toml

["pyproject.toml".tool.black]
line-length = 85

["setup.cfg".flake8]
max-line-length = 85
max-complexity = 12
ignore = D100,D101,D102,D103,D104,D105,D106,D107,D202,E203,W503
select = E241,C,E,F,W,B,B9

["setup.cfg"]
comma_separated_values = ["flake8.ignore", "flake8.exclude"]

Your Environment

  • nitpick version used: 0.16.1
  • Python version: 3.7.3 (via Homebrew)
  • Operating System and version: macOS 10.13.6

Stop gracefully when TOML is invalid

Your bug may already be reported!
Please search on the issue tracker before creating one.

Expected Behavior

The app should not break with an Exception on invalid TOML.

Current Behavior

Stack trace with toml.decoder.TomlDecodeError.

Possible Solution

The developer should get a message "Style file XXX.toml has invalid TOML formatting: ".

Steps to Reproduce

Style file:

["setup.cfg".flake8]
ignore = D100,D104,D202,E203,W503
# raises toml.decoder.TomlDecodeError: This float doesn't have a leading digit (line 7 column 1 char 110)
extend-select = E241,C,E,F,W,B,B9
# raises toml.decoder.TomlDecodeError: This float doesn't have a leading digit (line 8 column 1 char 146)
foo = 1,2,3
# raises toml.decoder.TomlDecodeError: invalid literal for int() with base 0: '1,2,3' (line 9 column 1 char 182)

Context

Your Environment

  • nitpick version used: 0.16.1

  • Python version: 3.7.4

  • Operating System and version: macOS 10.14.5 (18F132)

  • Link to your project:

  • Run the following commands and paste the output:

    which python3
    python3 -V
    pip freeze
    cat $(which flake8)
~ ๏ฃฟ     which python3
/Users/andreoliwa/my_envs/nitpick_bug/bin/python3
~ ๏ฃฟ     python3 -V
Python 3.7.4
~ ๏ฃฟ     pip freeze
attrs==19.1.0
certifi==2019.6.16
chardet==3.0.4
dictdiffer==0.8.0
entrypoints==0.3
flake8==3.7.8
idna==2.8
jmespath==0.9.4
mccabe==0.6.1
nitpick==0.16.1
pycodestyle==2.5.0
pyflakes==2.1.1
python-slugify==3.0.3
requests==2.22.0
ruamel.yaml==0.16.0
ruamel.yaml.clib==0.1.0
sortedcontainers==2.1.0
text-unidecode==1.2
toml==0.10.0
urllib3==1.25.3
~ ๏ฃฟ     cat $(which flake8)
#!/Users/andreoliwa/my_envs/nitpick_bug/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from flake8.main.cli import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
~ ๏ฃฟ

For more information, see the CONTRIBUTING guide.

Check tox.ini

Expected Behavior

Enforce the use of tox with a certain configuration.

Current Behavior

The file is not being checked.

Possible Solution

This is an old solution, not valid/needed anymore with the plugin system:

# Or IniFile or ConfigParserIni as the parent class,
# depending on the format used by tox
class ToxIni(BaseFile):
  • tox.ini should be working since #267
  • Add as a default style
  • Multiline options (e.g.: commands, omit (coverage) will be done in #271
  • Test if the file is applied in a new project

Infinite loop in generic.climb_directory_tree

Expected Behavior

I expect 'nitpick' to complete in few minutes

Current Behavior

I get endless completion time.
I think it's happens because of behaviour of Path().root and Path().parent on windows

>>> Path('c:/')
WindowsPath('c:/')
>>> Path('c:/').root
'\\'
>>> Path('c:/').parent
WindowsPath('c:/')

Steps to Reproduce

  1. Run flake8
  2. Get endless execution

Your Environment

  • nitpick version used: 0.21.1

  • Python version: Python 3.7.4

  • Operating System and version: Windows 10

  • Run the following commands and paste the output:

    (venv) C:\Users\Sleip\Desktop\Git\poe_gems_requirements>where python
    C:\Users\Sleip\Desktop\Git\poe_gems_requirements\venv\Scripts\python.exe
    C:\Users\Sleip\AppData\Local\Programs\Python\Python37-32\python.exe
    
    (venv) C:\Users\Sleip\Desktop\Git\poe_gems_requirements>python -V
    Python 3.7.4
    
    (venv) C:\Users\Sleip\Desktop\Git\poe_gems_requirements>pip freeze
    altgraph==0.16.1
    astor==0.8.0
    atomicwrites==1.3.0
    attrs==19.2.0
    bandit==1.6.2
    certifi==2019.9.11
    chardet==3.0.4
    Click==7.0
    colorama==0.3.9
    dictdiffer==0.8.0
    docutils==0.15.2
    entrypoints==0.3
    eradicate==1.0
    flake8==3.7.8
    flake8-annotations-complexity==0.0.2
    flake8-bandit==2.1.2
    flake8-broken-line==0.1.1
    flake8-bugbear==19.8.0
    flake8-builtins==1.4.1
    flake8-coding==1.3.2
    flake8-commas==2.0.0
    flake8-comprehensions==2.2.0
    flake8-debugger==3.1.1
    flake8-docstrings==1.5.0
    flake8-eradicate==0.2.2
    flake8-executable==2.0.3
    flake8-isort==2.7.0
    flake8-logging-format==0.6.0
    flake8-pep3101==1.2.1
    flake8-polyfill==1.0.2
    flake8-print==3.1.1
    flake8-quotes==2.1.0
    flake8-rst-docstrings==0.0.11
    flake8-string-format==0.2.3
    future==0.18.0
    gitdb2==2.0.6
    GitPython==3.0.3
    idna==2.8
    importlib-metadata==0.23
    isort==4.3.21
    jmespath==0.9.4
    mando==0.6.4
    marshmallow==3.2.1
    marshmallow-polyfield==5.7
    mccabe==0.6.1
    more-itertools==7.2.0
    nitpick==0.21.1
    packaging==19.2
    pbr==5.4.3
    pefile==2019.4.18
    pep8-naming==0.8.2
    pluggy==0.13.0
    py==1.8.0
    pycodestyle==2.5.0
    pydocstyle==4.0.1
    pyflakes==2.1.1
    Pygments==2.4.2
    PyInstaller==3.5
    pyparsing==2.4.2
    pytest==5.2.1
    python-slugify==3.0.6
    pywin32-ctypes==0.2.0
    PyYAML==5.1.2
    radon==2.4.0
    requests==2.22.0
    restructuredtext-lint==1.3.0
    ruamel.yaml==0.16.5
    ruamel.yaml.clib==0.2.0
    six==1.12.0
    smmap2==2.0.5
    snowballstemmer==2.0.0
    sortedcontainers==2.1.0
    stevedore==1.31.0
    testfixtures==6.10.0
    text-unidecode==1.3
    toml==0.10.0
    typing-extensions==3.7.4
    urllib3==1.25.6
    wcwidth==0.1.7
    wemake-python-styleguide==0.12.5
    zipp==0.6.0

Multiple entries in tool.nitpick doesn't work.

Add this section to pyproject.yml

[tool.nitpick]
style = [
  "https://raw.githubusercontent.com/wemake-services/wemake-python-styleguide/master/styles/nitpick-style-wemake.toml",
  "./nitpick.toml",
]

Expected Behavior

Running nitpick via flake8 should ensure that settings overridden in local nitpick.toml should be honoured.

Current Behavior

I get an error

Traceback (most recent call last):
  File "/Users/gghildyal/.pyenv/versions/cognito-3.8.3/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/flake8/main/application.py", line 360, in run
    self._run(argv)
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/flake8/main/application.py", line 348, in _run
    self.run_checks()
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/flake8/main/application.py", line 262, in run_checks
    self.file_checker_manager.run()
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/flake8/checker.py", line 325, in run
    self.run_serial()
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/flake8/checker.py", line 309, in run_serial
    checker.run_checks()
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/flake8/checker.py", line 589, in run_checks
    self.run_ast_checks()
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/flake8/checker.py", line 496, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/nitpick/flake8.py", line 51, in run
    yield from itertools.chain(app.config.merge_styles(), self.check_files(True), self.check_files(False))
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/nitpick/config.py", line 66, in merge_styles
    style.find_initial_styles(configured_styles)
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/nitpick/style.py", line 66, in find_initial_styles
    self.include_multiple_styles(chosen_styles)
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/nitpick/style.py", line 92, in include_multiple_styles
    style_path = self.get_style_path(style_uri)  # type: Optional[Path]
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/nitpick/style.py", line 121, in get_style_path
    style_path = self.fetch_style_from_url(clean_style_uri)
  File "/Users/gghildyal/.pyenv/versions/3.8.3/envs/cognito-3.8.3/lib/python3.8/site-packages/nitpick/style.py", line 162, in fetch_style_from_url
    raise FileNotFoundError("Error {} fetching style URL {}".format(response, new_url))
FileNotFoundError: Error <Response [404]> fetching style URL https://raw.githubusercontent.com/wemake-services/wemake-python-styleguide/master/styles/./nitpick.toml
make: *** [lint] Error 1
  • It seems like the code remembers the first github line and tries to apply the second entry to that parent link.
  • Reversing the order, first a local file and then a github link also doesn't work but the error is a bit weird, it says file-structure.toml not found.

Possible Solution

Steps to Reproduce

As in summary above.

Context

I am trying to use all styles from wemake-style-guide but increase the line length from 80 to 88. I am unable to do that at the moment.

Your Environment

  • nitpick version used: 0.23

  • Python version: 3.8.3

  • Operating System and version: MacOS

Strange message about pre-commit from nitpick

Expected Behavior

I expect that pre-commit won't be mentioned in nitpick reports. Because I don't use it and I don't have references of it in my style files.

Current Behavior

nitpick reports about missing key in .pre-commit-config.yaml. Why?

Link to the CI: https://travis-ci.org/wemake-services/wemake-django-template/builds/586597805#L793
Link to the source code: https://github.com/wemake-services/wemake-django-template/blob/f108ed5aae4b88006f61d8cfa215f3f3699d1509/%7B%7Bcookiecutter.project_name%7D%7D/pyproject.toml#L7
Link to the styles/ folder: https://github.com/wemake-services/wemake-python-styleguide/blob/master/styles

Check .pylintrc

Expected Behavior

  • Enforce use of pylint.
  • Check .pylintrc and its values.

Current Behavior

.pylintrc is not being checked.

Possible Solution

This is an old solution, not valid/needed anymore with the plugin system:

class PylintRcFile(BaseFile):
  • .pylintrc is also an INI file, so it should be working since #267
  • Add as a default style
  • Multiline options will be done in #271
  • Test if the file is applied in a new project

comma_separated_values did not work for some argument

Expected Behavior

In my style file

["setup.cfg".flake8]
ignore = "W503,E203,FI58,PT003,C408"
exclude = "venv*,**/migrations/"
per-file-ignores = "tests/**.py:FI18,setup.py:FI18"

[nitpick.files."setup.cfg"]
comma_separated_values = ["flake8.ignore", "flake8.exclude", "falek8.per-file-ignores"]

and setup.cfg

[flake8]
exclude = venv*,**/migrations/
ignore = W503,E203,FI12,FI15,FI16,FI17,FI18,FI50,FI51,FI53,FI54,FI55,FI58,PT003,C408
per-file-ignores = tests/**.py:FI18,setup.py:FI18,tests/**.py:BZ01

When I run flake8 . I expect to there are no error but flake8 blame me like below.

Current Behavior

./tests/__init__.py:0:1: NIP323 File setup.cfg: [flake8]per-file-ignores is tests/**.py:FI18,setup.py:FI18,tests/**.py:BZ01 but it should be like this:
[flake8]
per-file-ignores = tests/**.py:FI18,setup.py:FI18

Possible Solution

Maybe fix parsing logic...?

Steps to Reproduce

  1. fill style file like above
  2. fill setup.cfg like above
  3. run flake8 . on root directory

Your Environment

/Users/isac.yoo/Library/Caches/pypoetry/virtualenvs/buzzvil-python-styleguide-wLohAt5O-py3.9/bin/python3

Python 3.9.0

appdirs @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/47/cf/4f/4ef02fb715aa36daeebad18cc5570126159c659c41c7b5ec46a7387d9b/appdirs-1.4.4-py2.py3-none-any.whl
attrs @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/fb/1a/c6/6103c773c75c58dfe3575697b2d5d9242f3c1abda90b6fae3b36cbcb0d/attrs-20.2.0-py2.py3-none-any.whl
black @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/56/00/d0/a3bee2cbd161f599bac7d8ee24fb2b17aeba39b53bc42724de21f352bf/black-20.8b1.tar.gz
certifi @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/21/05/56/449b96ff701697c4cc1601fdacb878ed935f7eac76b99971b346b8ef9d/certifi-2020.6.20-py2.py3-none-any.whl
chardet @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/8f/6f/1c/8085d730ad63c462222af30d0d01c4bd0caca5287e40b63c1fe8f529b7/chardet-3.0.4-py2.py3-none-any.whl
click @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/e2/79/34/a23e9d2f683ed66be11ec3bd760dec3a2fe228cfdedf2071bcf0531b06/click-7.1.2-py2.py3-none-any.whl
dictdiffer @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/89/cd/10/56605467e905287a1404203b6fd708ad810132b18fa01a03f5e2db6d5e/dictdiffer-0.8.1-py2.py3-none-any.whl
dlint @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/7b/62/45/b39111d9e2cb63b46494bde16cfe5ce049d58fe3f9cd9e7da6da8d35c7/dlint-0.11.0-py2.py3-none-any.whl
eradicate @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/12/ce/ac/197035fe6d51568abb7ea160f5ad416d2164a2010005e8356b8229e550/eradicate-2.0.0.tar.gz
flake8 @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/4f/88/2e/d38cf0f4194842739925b11c47e3143194778609f5ebc1997b71de0b21/flake8-3.8.4-py2.py3-none-any.whl
flake8-annotations-complexity @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/36/2a/8c/1480d6c411b2dcd6f7f452e31266b8b8bbe178c40823202f9fc3adca9f/flake8_annotations_complexity-0.0.5.tar.gz
flake8-black @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/28/43/3d/5bcd96af9b684c11984eb821e9c8355bd9268b844e366a15f53f5db0d5/flake8-black-0.2.1.tar.gz
flake8-blind-except @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/b4/80/6c/badab07a60249dad058845f23f2b3438b78c3b5786a3eaea9645172984/flake8-blind-except-0.1.1.tar.gz
flake8-bugbear @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/23/1d/31/0d3d3387d7003553b5a2a762c7cc46a5806152b2ffa1e7da9ea48ada9f/flake8_bugbear-20.1.4-py36.py37.py38-none-any.whl
flake8-builtins @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/21/84/db/7a82d055eb4c2280b774d4ce298b6ffed7bd8acffe0d03e5e6947dd310/flake8_builtins-1.5.3-py2.py3-none-any.whl
flake8-comprehensions @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/6b/7e/03/30d2bd99c7fb9c3925cbb25737d66b60f0cd2ed3d14899987c85acf17a/flake8_comprehensions-3.3.0-py3-none-any.whl
flake8-eradicate @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/99/8a/26/95fdb311c16f732e009ab3febcd098f7287b47ae77d547d51f8e69027e/flake8_eradicate-1.0.0-py3-none-any.whl
flake8-functions @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/d3/7a/ea/0e44a4cd55f27690dc2eaddb0519f629fedb548260057232749313fe4e/flake8_functions-0.0.4-py3-none-any.whl
flake8-future-import @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/88/6a/60/61ff387e9b81ff5dc12892134679999111e6a7294738c05256355a502f/flake8_future_import-0.4.6-py2.py3-none-any.whl
flake8-keyword-arguments @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/e8/6c/64/324505d15ce1f308813ffff573b5fdc47bfb2f12ce3588fc7bdfe6bc4a/flake8_keyword_arguments-0.1.0-py3-none-any.whl
flake8-mutable @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/0b/5f/b4/e198dacfee1e44f05fa19150e4e2abeee61f823b172dc47803810ae379/flake8-mutable-1.2.0.tar.gz
flake8-plugin-utils @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/05/01/93/d85d5e280ed56eaf6400f1215ca97460ff0d1aca89497cfc6a770d5b91/flake8_plugin_utils-1.3.1-py3-none-any.whl
flake8-polyfill @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/28/17/cc/952c11cd5ffb2608137557f928dc4f9365b4dbe1e2a6015eeea78583ac/flake8_polyfill-1.0.2-py2.py3-none-any.whl
flake8-pytest-style @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/cd/d6/4c/22ac1d44114fd037192385dca5364fc4f9e7671f4fb1d907b0aa7cf28d/flake8_pytest_style-1.3.0-py3-none-any.whl
identify @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/ef/35/b1/9305ae6b813bce6ef58234803083ead07b2b7b28e03a08c18a6c3dcc3e/identify-1.5.9-py2.py3-none-any.whl
idna @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/ef/7f/a9/19cc0b8760bdf6f696290c06532496f8bb29fbdaad044f852fed00ec82/idna-2.10-py2.py3-none-any.whl
iniconfig @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/fa/b0/c6/10cfac68c9e6de9d2a1678366ca89fd9292b362c1760dbe758e41691cb/iniconfig-1.1.1-py2.py3-none-any.whl
jmespath @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/2c/f0/52/b0ba93d941bd49c8719dee7ca27d2096bf96e17948667388c3ee2ac8f8/jmespath-0.10.0-py2.py3-none-any.whl
marshmallow @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/96/b7/07/7de906958a6f35b490e21a970f5c665cf2662c4600d128b29ba046c4fd/marshmallow-3.9.0-py2.py3-none-any.whl
marshmallow-polyfield @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/11/46/19/129f4f42a2731df90af6d8cf8147dbf95a6a357c45a15bb2a6f3171004/marshmallow-polyfield-5.9.tar.gz
mccabe @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/96/5e/5f/21ae5296697ca7f94de4da6e21d4936d74029c352a35202e4c339a4253/mccabe-0.6.1-py2.py3-none-any.whl
more-itertools @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/7d/18/5b/12afd5e33694faf95db51e22aa54cfa3d1bafccb3829da451c61f5147a/more_itertools-8.6.0-py3-none-any.whl
mypy @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/27/70/0f/dedc216f4bb804889f12f78af571efe8280e5035b50e106e0d65409504/mypy-0.790-py3-none-any.whl
mypy-extensions @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/92/45/bf/1807ce854ff668d92602207a37bfa9316def2a3f257bd03c4c5be4bc9b/mypy_extensions-0.4.3-py2.py3-none-any.whl
nitpick @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/06/57/8e/f4addeef60b3d40e06d94c1339dc3a03672737f32116c0061bb4e524a2/nitpick-0.23.1-py3-none-any.whl
packaging @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/c2/db/fd/1c4b276e8eb8d548bc667eb79d0e46e6e0e33e016805c22b95e7a72836/packaging-20.4-py2.py3-none-any.whl
pathspec @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/e4/03/ac/1840dd6347740ddd832fbd2ce386491d30dfb418470eee2557cc4aff9b/pathspec-0.8.0-py2.py3-none-any.whl
pep8-naming @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/a4/93/c7/a3b9b8b4aef682b4caa67015d897aff3d064860a460124ad8a23b6f45f/pep8_naming-0.11.1-py2.py3-none-any.whl
pluggy @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/29/58/fc/ed8b7451d3ef91a6465024f5656141da996e7aafd4d41a1659629a75e7/pluggy-0.13.1-py2.py3-none-any.whl
py @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/8b/d2/99/c011698bd549f30497b27bee2731848753a014313ed783267c74b6dcde/py-1.9.0-py2.py3-none-any.whl
pycodestyle @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/00/8e/03/5dd26ed1283fc5849fa141c87a1d99659b252d7a2105d6ec509c6de6cd/pycodestyle-2.6.0-py2.py3-none-any.whl
pyflakes @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/c6/a2/76/8815e047ae91abaf39cdde4a16f52907ed96ae14e12a498dd0704cb43a/pyflakes-2.2.0-py2.py3-none-any.whl
pyparsing @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/92/0f/cf/effdcd5d76a6186df0969f85b3b030284ff8058936d5016540b5258ea3/pyparsing-2.4.7-py2.py3-none-any.whl
pytest @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/51/2b/69/0ed871e9892cd17ac62114915ee43c391fee90b73004344382be06b388/pytest-6.1.2-py3-none-any.whl
python-slugify @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/c7/a7/df/f5e1ea59556a505b43a42b5730c4db933dbde2f994747f2af3dd185fa1/python-slugify-4.0.1.tar.gz
regex @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/8e/c6/90/82166b2ff9a80d02be7cc554d160638e3656ac47245a253b8585591fb1/regex-2020.10.28-cp39-cp39-macosx_10_9_x86_64.whl
requests @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/c8/71/24/b6c0095afdab8413168a4547362ea8d0a5ea62f987aeab4491a614683e/requests-2.24.0-py2.py3-none-any.whl
ruamel.yaml @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/e3/77/60/c6e35eb5461cad7856f44e8108e59233a37c83041ce3e4055d79d42476/ruamel.yaml-0.16.12-py2.py3-none-any.whl
six @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/dd/1c/65/ad0dea11136f5a869f072890a0eea955aa8fc35b90c85c55249fd3abfe/six-1.15.0-py2.py3-none-any.whl
sortedcontainers @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/48/0f/c2/ded1564076c6d1cb40158163d236954eb9e5124e57d9be895219db8663/sortedcontainers-2.2.2-py2.py3-none-any.whl
text-unidecode @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/34/f9/c2/484c44b08bab89d472229bbd257fcc1d1c6273ee027f01cb08c4e3c309/text_unidecode-1.3-py2.py3-none-any.whl
toml @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/6b/6a/c9/53b19f7870a77d855e8b05ecdc98193944e5d246dafe11bbcad850ecba/toml-0.10.2-py2.py3-none-any.whl
typed-ast @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/31/2b/fd/ae2dba5a915c33575ab7e0fa78d5ce3ce6eee3c7657e00608d740175b8/typed_ast-1.4.1-cp39-cp39-macosx_10_15_x86_64.whl
typing-extensions @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/ab/c3/72/446cb2c521f10fc837619e8a7c68ed3c3bd74859bd625b7d74f38a159b/typing_extensions-3.7.4.3-py3-none-any.whl
urllib3 @ file:///Users/isac.yoo/Library/Caches/pypoetry/artifacts/d8/4b/3f/9e8027e7f15b2f99244ad505328c3cf87912ad87446c1c8e89efacf731/urllib3-1.25.11-py2.py3-none-any.whl

#!/Users/isac.yoo/Library/Caches/pypoetry/virtualenvs/buzzvil-python-styleguide-wLohAt5O-py3.9/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from flake8.main.cli import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Can not fetch URL without .toml extension

Expected Behavior

Does not complain when a style file URL does not end with .toml

Current Behavior

โžœ flake8             
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/<user>/.pyenv/versions/3.7.5/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/checker.py", line 666, in _run_checks
    return checker.run_checks()
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/checker.py", line 502, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/nitpick/plugin.py", line 50, in run
    Nitpick.current_app().config.merge_styles(), self.check_files(True), self.check_files(False)
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/nitpick/config.py", line 65, in merge_styles
    style.find_initial_styles(configured_styles)
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/nitpick/style.py", line 61, in find_initial_styles
    self.include_multiple_styles(chosen_styles)
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/nitpick/style.py", line 76, in include_multiple_styles
    style_path = self.get_style_path(style_uri)  # type: Optional[Path]
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/nitpick/style.py", line 105, in get_style_path
    style_path = self.fetch_style_from_url(clean_style_uri)
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/nitpick/style.py", line 132, in fetch_style_from_url
    raise FileNotFoundError("Error {} fetching style URL {}".format(response, new_url))
FileNotFoundError: Error <Response [401]> fetching style URL https://gitlab.com/api/v4/snippets/1954943/raw.toml
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/<user>/.pyenv/versions/<venv>/bin/flake8", line 10, in <module>
    sys.exit(main())
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/main/cli.py", line 18, in main
    app.run(argv)
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/checker.py", line 329, in run
    self.run_parallel()
  File "/Users/<user>/.pyenv/versions/3.7.5/envs/<venv>/lib/python3.7/site-packages/flake8/checker.py", line 293, in run_parallel
    for ret in pool_map:
  File "/Users/<user>/.pyenv/versions/3.7.5/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
FileNotFoundError: Error <Response [401]> fetching style URL https://gitlab.com/api/v4/snippets/1954943/raw.toml<user>

Possible Solution

Do not append .toml to style file URL when fetching it.

Steps to Reproduce

  1. Add "https://gitlab.com/api/v4/snippets/1954943/raw" to [tool.nitpick] style =...
  2. Run flake8

Context

I was trying to use a GitLab snippet to store my config. GitLab snippets' URL do not change across edition but GitHub's do.

Your Environment

  • nitpick version used: 0.21.4

  • Python version: 3.7.5

  • Operating System and version: macOS 10.14.6

CLI: Remove flake8 dependency, run with pre-commit

Expected Behavior

When running Nitpick, display the correct filenames that contain violations.

Simulate the output of a flake8 plugin, so warnings can be displayed together with tools that use the flake8 format.
If possible, display the correct line and column of the violation.

Also, without relying on flake8, Nitpick can be used for any language, not only for Python projects.
There would be no need to create dummy.py files.

Example output:

$ pre-commit run --all-files nitpick
Nitpick..................................................................Failed
- hook id: nitpick
- exit code: 1

.pre-commit-config.yaml:3:5: NIP339 hook 'debug-statements' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
.pre-commit-config.yaml:3:5: NIP339 hook 'end-of-file-fixer' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
.pre-commit-config.yaml:3:5: NIP339 hook 'trailing-whitespace' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
.pre-commit-config.yaml:9:5: NIP339 hook 'pyupgrade' (rev: v2.4.4) has different values. Use this:
rev: v2.4.1
.pre-commit-config.yaml:50:5: NIP339 hook 'flake8' (rev: 3.8.2) has different values. Use this:
rev: 3.8.1
setup.cfg:25:1: NIP324 section [flake8] has some missing key/value pairs. Use this:
[flake8]
exclude = .tox,build
pyproject.toml:55:1: NIP318 missing values:
[tool.poetry.dev-dependencies]
pylint = "*"

Current Behavior

Nitpick is a flake8 plugin, and flake8 only runs on Python .py files.
Currently, Nitpick chooses an arbitrary Python file and displays all the flake8 warnings as if they were violations of that Python file.
This was mentioned on #73 (comment)

Below is an example of how Nitpick works now.
All violations are displayed under docs/conf.py, line 0, column 1.

$ pre-commit run --all-files nitpick
Nitpick..................................................................Failed
- hook id: nitpick
- exit code: 1

docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'debug-statements' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'end-of-file-fixer' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'trailing-whitespace' (rev: v3.1.0) has different values. Use this:
rev: v3.0.0
docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'pyupgrade' (rev: v2.4.4) has different values. Use this:
rev: v2.4.1
docs/conf.py:0:1: NIP339 File .pre-commit-config.yaml: hook 'flake8' (rev: 3.8.2) has different values. Use this:
rev: 3.8.1
docs/conf.py:0:1: NIP324 File setup.cfg: section [flake8] has some missing key/value pairs. Use this:
[flake8]
exclude = .tox,build
docs/conf.py:0:1: NIP318 File pyproject.toml has missing values:
[tool.poetry.dev-dependencies]
pylint = "*"

Possible Solution

  1. Run a CLI command like nitpick run to check files.
  2. Accept zero or more files as arguments.
    Check only the desired files, of check all files if no arguments were provided.
    This would make it compatible with the files attribute on pre-commit.
  3. Make flake8 an optional dependency.
    Nitpick would be installed with poetry add --dev --extras flake8 nitpick or pip install nitpick[flake8].
  4. Try to parse the violated config file in order to determine the line and column of the violation.

Strange behaviour with wemake-python-styleguide

Your bug may already be reported!
Please search on the issue tracker before creating one.

Expected Behavior

That's what I do:

  1. Clone https://github.com/wemake-services/wemake-python-styleguide
  2. poetry install
  3. poetry add --dev nitpick
  4. Then I add this configuration to nitpick-style.toml:
# Default style file for nitpick
# https://raw.githubusercontent.com/andreoliwa/nitpick/v0.18.0/nitpick-style.toml

[nitpick]
minimum_version = "0.10.0"

["setup.cfg".flake8]
enable-extensions = "G"
  1. When I run flake8 . that's what I get:
ยป flake8 .

./tests/test_version.py

  1:1      NIP312 File pyproject.toml should be deleted
  # -*- coding: utf-8 -*-
  ^

Full list of violations and explanations:
https://wemake-python-stylegui.de/en/0.11.1/pages/usage/violations/

I am not sure why I should delete my pyproject.toml ๐Ÿ™‚

Check .gitignore and .dockerignore

Expected Behavior

Check ignore files like .gitignore and .dockerignore.

Current Behavior

They are not being checked.

Possible Solution

Use #165 to represent these ignore files, but #183 should be done first though.

This solution below is not valid anymore:

class IgnoreFile(BaseFile):
    pass
class GitIgnore(IgnoreFile):
    pass
class DockerIgnore(IgnoreFile):
    pass

Files that begin with `.`

Expected Behavior

I create this style preset:

[nitpick.files.".editorconfig"]
missing_message = "Create .editorconfig file"

I want to be sure that this file always exists.

Current Behavior

But, that's what I get:

ยป flake8 .

./tests/test_version.py

  1:1      NIP001 File editorconfig.toml has an incorrect style. Invalid TOML:
TomlDecodeError: Invalid group name 'editorconfig"'. Try quoting it. (line 3 column 1 char 30)
  # -*- coding: utf-8 -*-

How can I start filename with the . char?

Check if lines exist on a text file

Expected Behavior

Check if one or more lines exist in a certain text file.

Current Behavior

There is no such validation.

Possible Solution

Accept a configuration like this:

[["requirements.txt".contains]]
line = "sphinx>=1.3.0"

Context

Closes #162.

Enforce absence of keys

Expected Behavior

Configure the style with the keys that should not exist in pyproject.toml, setup.cfg and other files.

Current Behavior

Right now flake8-nitpick only checks if keys and values are present in config files.
Sometimes we want to enforce that some keys/values are not present in those files.

Possible Solution

class BaseFile(...):
    @abc.abstractmethod
    def check_absent_values(self) -> YieldFlake8Error:
        pass

Context

Some examples:

  • pep257, pycodestyle should not be dependencies on pyproject.toml (other flake8 plugins already take care of it);
  • pur should not be a dependency (poetry replaces its need).

Check .editorconfig

Problem

I want to enforce my file types and their configs on .editorconfig.

Possible Solution

This is an old solution, not valid/needed anymore with the plugin system:

class ConfigParserIni(BaseFile):
    pass
class EditorConfig(ConfigParserIni):
    pass
# Also change the parent of the setup.cfg class
class SetupCfg(ConfigParserIni):
    pass
  • Handle .editorconfig as an INI file
  • Add .editorconfig as a default style
  • Test application in a new project

Pre-commit: compare missing and different keys on hooks

Expected Behavior

Different values on hooks' keys should also trigger flake8 errors.

Current Behavior

Only the presence of the hook is checked, by its id value.
If any of the values on .pre-commit-config.yaml is different from the style file, no error is raised.

Possible Solution

Find a better way to store partial YAML configuration on the nitpick style.

Right now it's better to store it as a multiline YAML partial string.
It's easier to just copy and paste from a real YAML file.

And this string is not 100% valid YAML, because it is just a "slice" of a YAML file.

YAML is converted to a dict internally, but storing it in the TOML file would be really ugly for the human eye.
And people would just need to convert YAML to dict, then put in the style .toml file... not practical at all.

Maybe considering the indentation in the style file as a starting point to determine the nesting level of the YAML.

E.g: 2 spaces in the front mean those keys are below another level.

# The original YAML has a parent key here at this level
  - some_nested_key:
    - item 1
    - item 2
  - another_nested_key:
    - item 3
    - item 4

E.g: 4 spaces in the front mean those keys are 2 levels deep.

# The original YAML has a parent key here at this level
  # There is yet another child here
    - some_nested_key:
      - item 1
      - item 2
    - another_nested_key:
      - item 3
      - item 4

Formatting raises on the systems without colours

Expected Behavior

I expect nitpick to run with no exceptions. But that's what I get:
wemake-services/wemake-python-styleguide#794

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/click/termui.py", line 372, in style
    bits.append('\033[%dm' % (_ansi_colors.index(fg) + 30))
ValueError: tuple.index(x): x not in tuple
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 666, in _run_checks
    return checker.run_checks()
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 502, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/usr/local/lib/python3.7/site-packages/nitpick/plugin.py", line 58, in run
    yield from checker.check_exists()
  File "/usr/local/lib/python3.7/site-packages/nitpick/files/base.py", line 87, in check_exists
    yield from self.check_rules()
  File "/usr/local/lib/python3.7/site-packages/nitpick/files/setup_cfg.py", line 67, in check_rules
    yield from self.show_missing_keys(section, key, values)
  File "/usr/local/lib/python3.7/site-packages/nitpick/files/setup_cfg.py", line 106, in show_missing_keys
    yield self.flake8_error(4, ": section [{}] has some missing key/value pairs. Use this:".format(section), output)
  File "/usr/local/lib/python3.7/site-packages/nitpick/mixin.py", line 20, in flake8_error
    click.style("\n{}".format(suggestion.rstrip()), fg="bright_green") if suggestion else ""
  File "/usr/local/lib/python3.7/site-packages/click/termui.py", line 374, in style
    raise TypeError('Unknown color %r' % fg)
TypeError: Unknown color 'bright_green'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/flake8/main/cli.py", line 18, in main
    app.run(argv)
  File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 329, in run
    self.run_parallel()
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 293, in run_parallel
    for ret in pool_map:
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 354, in <genexpr>
    return (item for chunk in result for item in chunk)
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
TypeError: Unknown color 'bright_green'

Steps to Reproduce

  1. Create a Pull Request to https://github.com/wemake-services/wemake-django-template

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Dependabot couldn't fetch all your path-based dependencies

Dependabot couldn't fetch one or more of your project's path-based Python dependencies. The affected dependencies were docs/setup.py.

To use path-based dependencies with Dependabot the paths must be relative and resolve to a directory in this project's source code.

You can mention @dependabot in the comments below to contact the Dependabot team.

Enforce presence of keys (with any values)

My current use-case is that I am working on pyproject.toml styles.
I want

[build-system]
requires = ...
build-backend = ...

to be set to any values. But, I want them set.
Currently, I cannot find any ways to do this.

Related #10

Get style file from python package

Expected Behavior

tool.nitpick.style of pyproject.toml can load style which in some python package.

Current Behavior

tool.nitpick.style accept absolute file path or URL

Possible Solution

Structure of some_python_package

src/some_python_package
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ plugin.py
โ”œโ”€โ”€ plugin.pyi
โ”œโ”€โ”€ py.typed
โ””โ”€โ”€ styles
    โ”œโ”€โ”€ black.toml
    โ”œโ”€โ”€ flake8.toml
    โ”œโ”€โ”€ mypy.toml
    โ””โ”€โ”€ nitpick-style.toml

String way

pyproject.toml

[tool.nitpick]
style = "pypackage://some_python_package.styles.nitpick-style.toml"

Dict way

pyproject.toml

[tool.nitpick]
style = { module: "some_python_package.styles", resource: "nitpick-style.toml" }

Context

My company has dozens of python projects. We have company wide flake8 rules and I want to share tool configurations across those projects with the flake8 rules. So I created a flake8 plugin and include nitpick-style.toml. But because nitpick only accept pure file path, I can not reference the nitpick-style.toml.

ini-style comma separated lists and nitpick

Expected Behavior

I have this setting:

["setup.cfg".flake8]
ignore = "D100,D104,D401,W504,RST303,RST304"

And in my setup.cfg I have the following:

[flake8]
# Exclude some pydoctest checks globally:
ignore = D100, D104, D401, W504, RST303, RST304

Current Behavior

ยป flake8 .

./tests/test_version.py
  0:1      NIP323 File setup.cfg: [flake8]ignore is D100, D104, D401, W504, RST303, RST304 but it should be like this:
[flake8]
ignore = D100,D104,D401,W504,RST303,RST304

That's not what I expect for several reasons:

  1. Spacing is not important in this case
  2. If I try to add more values to the project's ignore-list - it breaks the check (try adding D101 for example). Sometimes projects do have different ignore rules due to different legacy, plugins, reasons.
  3. Ordering is also not important in this case. But it is checked right now.

Possible Solution

Use code in ignore check. All instances from the toml file must be present.
We can have more items in setup.cfg.

@andreoliwa what do you think?

Invalid config: nitpick.files."pyproject.toml": Unknown file.

Expected Behavior

I expect everything to work correctly with 0.21, the same way it was with 0.20.

Current Behavior

./docs/conf.py
  0:1      NIP001 File .cache/nitpick/https-raw-githubusercontent-com-wemake-services-wemake-python-styleguide-master-styles-poetry-toml.toml has an incorrect style. Invalid config:
nitpick.files."pyproject.toml": Unknown file. See https://nitpick.rtfd.io/en/latest/nitpick_section.html#nitpick-files.

CI job: https://travis-ci.org/dry-python/returns/jobs/577166238
nitpick declaration: https://github.com/dry-python/returns/blob/master/pyproject.toml#L7

File poetry.toml:

[nitpick.files."pyproject.toml"]
missing_message = "Install poetry and run 'poetry init' to create it"

I am not sure what's wrong.

fix: allow leading dash for dot files on the TOML style

Expected Behavior

Represent files that start with a dot on the style file.
TOML syntax does not allow keys starting with a dot.

Current Behavior

The dot is not part of the key when writing the style, like in [["pre-commit-config.yaml".repos]].
Since this is a specific file, the plugin handles it and adds the dot.

But this won't work for generic files; specific handling would have to be done for specific files.

Possible Solution

Using a dash in the beginning of the key to represent a dot.
Nitpick would replace a leading dash by a leading dot.
Examples of TOML sections:

[["-pre-commit-config.yaml".repos]]
[["-gitignore".contains]]
[["-dockerignore".contains]]

A dash is a valid first char for a TOML key, and I don't recall configuration files that start with a dash.

Context

After this it will be possible to use generic dot files in the Nitpick style.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.