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

defined config overwritten by config further up directory tree #368

Open
jsnklln opened this issue Jan 8, 2015 · 6 comments
Open

defined config overwritten by config further up directory tree #368

jsnklln opened this issue Jan 8, 2015 · 6 comments

Comments

@jsnklln
Copy link

jsnklln commented Jan 8, 2015

In the read_config function first the "user" config file is read then the directory tree is searched for "local" config files. If any config files exist within the directory tree they overwrite what was defined in the file specified by using --config. I've made a fork and plan on issuing a pull request soon. BTW I have no idea what I'm doing.

jsnklln pushed a commit to jsnklln/pep8 that referenced this issue Jan 8, 2015
IanLee1521 added a commit that referenced this issue Feb 6, 2015
Remove the default of ~/.config/pep8, and instead parse that
explictly. If a command line option is passed using --config, then
it is the only config handled.
IanLee1521 added a commit that referenced this issue Feb 6, 2015
@IanLee1521
Copy link
Member

Closed with commit 19d9a82

@sigmavirus24
Copy link
Member

It seems like the fix for this issue essentially broke people relying on config files in $HOME/.config/. See also: https://gitlab.com/pycqa/flake8/issues/33

@jsnklln
Copy link
Author

jsnklln commented Feb 13, 2015

I've got to leave for the weekend but I wanted to include what I've found so far:

flake8 --version
2.3.0 (pep8: 1.6.1, mccabe: 0.3, pyflakes: 0.8.1) CPython 2.7.9 on Darwin

My python code:
x = "fsafdsafdsafdsafdsafdsafdsafdsafdsafdsafdsajfkdsajkfdsajkfdsjaklfdjsaklfjdsaklfjdkslajfkldsajklfdsajklfjdsaklfdsa"

My config:

[flake8]
max-line-length=100

Run it:

flake8 code.py
code.py:1:101: E501 line too long (119 > 100 characters)

That's goodish news.

In the process I ran across the fact that the .config/pep8 file is read when flake8 is run but the [flake8] section is used. When pep8 is run the .config/pep8 file is read but the [pep8] section is used. I haven't looked into why flake8 isn't pulling in the right file.

@sigmavirus24
Copy link
Member

@IanLee1521 should I file a separate issue for the regression or should we reopen this to cover it?

@IanLee1521
Copy link
Member

No, I think this was a regression introduced with some cleanup I did. See #380 for more details.

I've tested against flake8 2.3.0 and commit 3bbaa23 and this seems to be resolved.

$ cat bar.py
x = "fsafdsafdsafdsafdsafdsafdsafdsafdsafdsafdsajfkdsajkfdsajkfdsjaklfdjsaklfjdsaklfjdkslajfkldsajklfdsajklfjdsaklfdsa"

$ cat ~/.config/flake8
[flake8]
max-line-length=100

$ flake8 --version
2.3.0 (pep8: 1.6.1, mccabe: 0.3, pyflakes: 0.8.1) CPython 2.7.6 on Linux

$ flake8 bar.py
bar.py:1:80: E501 line too long (119 > 79 characters)

$ flake8 --version
2.3.0 (pep8: 1.6.1, mccabe: 0.3, pyflakes: 0.8.1) CPython 2.7.6 on Linux

$ flake8 bar.py
bar.py:1:101: E501 line too long (119 > 100 characters)

IanLee1521 added a commit that referenced this issue Mar 18, 2015
…d other places.

This fix reverts to the parsing of user config (~/.config/pep8), then local directory
config files, and finally overrides with cli options as was the behavior back in 1.5.7
@IanLee1521
Copy link
Member

I'm going to reopen this issue. I've reverted the majority of this fix in commit 435d1cb as it had some pretty serious repurcussions for flake8 users. I intend to circular back around and propose an improved solution to this that works for both pep8 and flake8, however, I've unfortunately not gotten as much time as I'd hoped to devote to that work.

@jsnklln -- In response to:

In the process I ran across the fact that the .config/pep8 file is read when flake8 is run but the [flake8] section is used. When pep8 is run the .config/pep8 file is read but the [pep8] section is used. I haven't looked into why flake8 isn't pulling in the right file.

I believe you're looking for https://gitlab.com/pycqa/flake8/blob/master/flake8/engine.py#L51 which returns a parser that looks for the [flake8] rather than [pep8] section in the config file.

@IanLee1521 IanLee1521 reopened this Mar 18, 2015
pointlessone added a commit to pointlessone/pep8 that referenced this issue Dec 29, 2016
2.2.0 (2016-11-14)
------------------

Bugs:

* Fixed E305 regression caused by PyCQA#400;
  PyCQA#593

2.1.0 (2016-11-04)
------------------

Changes:

* Report E302 for blank lines before an "async def";
  PyCQA#556
* Update our list of tested and supported Python versions which are 2.6,
  2.7, 3.2, 3.3, 3.4 and 3.5 as well as the nightly Python build and
  PyPy.
* Report E742 and E743 for functions and classes badly named 'l', 'O',
  or 'I'.
* Report E741 on 'global' and 'nonlocal' statements, as well as
  prohibited single-letter variables.
* Deprecated use of `[pep8]` section name in favor of `[pycodestyle]`;
  PyCQA#591

Bugs:

* Fix opt_type AssertionError when using Flake8 2.6.2 and pycodestyle;
  PyCQA#561
* Require two blank lines after toplevel def, class;
  PyCQA#536
* Remove accidentally quadratic computation based on the number of
  colons. This will make pycodestyle faster in some cases;
  PyCQA#314

2.0.0 (2016-05-31)
------------------

Changes:

* Added tox test support for Python 3.5 and pypy3
* Added check E275 for whitespace on `from ... import ...` lines;
  PyCQA#489 / PyCQA#491
* Added W503 to the list of codes ignored by default ignore list;
  PyCQA#498
* Removed use of project level `.pep8` configuration file;
  PyCQA#364

Bugs:

* Fixed bug with treating `~` operator as binary; PyCQA#383
  / PyCQA#384
* Identify binary operators as unary; PyCQA#484 /
  PyCQA#485

1.7.0 (2016-01-12)
------------------

Changes:

* Reverted the fix in PyCQA#368, "options passed on command
  line are only ones accepted" feature. This has many unintended
  consequences in pep8 and flake8 and needs to be reworked when I have
  more time.
* Added support for Python 3.5. (Issue PyCQA#420 &
  PyCQA#459)
* Added support for multi-line config_file option parsing. (Issue
  PyCQA#429)
* Improved parameter parsing. (Issues PyCQA#420 &
  PyCQA#456)

Bugs:

* Fixed BytesWarning on Python 3. (Issue PyCQA#459)
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

No branches or pull requests

3 participants