Commit graph

1616 commits

Author SHA1 Message Date
Ian Cordasco
429d8a196e
Diable multiprocessing behaviour on Windows
Due to https://bugs.python.org/issue27649, we cannot continue to
expect multiprocessing to work as we expect and document it on Windows.
As such, we are going to revert back to our previous behaviour of
disabling it across all versions of Python on Windows to provide the
default expected behaviour of Flake8 on that Operating System.
2016-07-29 07:04:37 -05:00
Ian Cordasco
530767d36d Merge branch 'bug/195' into 'master'
Allow plugins that are on by default to be ignored

*Description of changes*

Previously, users were unable to ignore the error code of a plugin that was on by default. This adds a tiny bit of extra logic to re-enable that behaviour.

*Related to:*  #195

See merge request !104
2016-07-29 00:43:07 +00:00
Ian Cordasco
c670217c24
Allow plugins that are on by default to be ignored
Previously, to ensure that plugins on by default were reported, we
added them to the select list. This means that ignoring them became
impossible. To accomodate our reporting logic and a user's ability
to ignore, we need to keep our select and extended select lists
separated.

This allows us to have a better understanding of who is selecting what,
where, and how and make our decision as to whether or not an error
should be reported more wisely.

Closes #195
2016-07-28 19:28:13 -05:00
Ian Cordasco
c0e5066577 Merge branch 'patch-1' into 'master'
Fix hyperlink in Links.



See merge request !102
2016-07-28 19:23:02 +00:00
Jason R. Coombs
3dd2c90f84 Fix hyperlink in Links. 2016-07-28 19:14:41 +00:00
Ian Cordasco
4fc4df2fc1 Merge branch 'raise_exception_when_plugin_entry_point_is_not_callable' into 'master'
Raise exception when entry_point not callable

Raise exception when entry_point not callable

E.g.:

```
$ .tox/flake8/bin/flake8 mobileweb
Traceback (most recent call last):
  File ".tox/flake8/bin/flake8", line 9, in <module>
    load_entry_point('flake8', 'console_scripts', 'flake8')()
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/cli.py", line 16, in main
    app.run(argv)
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 316, in run
    self._run(argv)
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 299, in _run
    self.initialize(argv)
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 289, in initialize
    self.find_plugins()
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 143, in find_plugins
    self.check_plugins.load_plugins()
  File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 375, in load_plugins
    plugins = list(self.manager.map(load_plugin))
  File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 267, in map
    yield func(self.plugins[name], *args, **kwargs)
  File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 373, in load_plugin
    return plugin.load_plugin()
  File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 173, in load_plugin
    raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "P999" due to Plugin <module 'teamcity.flake8_plugin' from '/Users/marca/dev/git-repos/teamcity-messages/teamcity/flake8_plugin.pyc'> is not a callable. It might be written for an older version of flake8 and might not work with this version.
```

This is nicer than the previous behavior of raising an obscure `PicklingError` and then hanging.

```
$ .tox/flake8/bin/flake8 mobileweb
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 268, in _feed
    send(obj)
PicklingError: Can't pickle <type 'module'>: attribute lookup __builtin__.module failed
```

*Related to:*  164

See merge request !101
2016-07-28 19:01:46 +00:00
Marc Abramowitz
d234f22e09 Raise exception when entry_point not callable
E.g.:

```
$ .tox/flake8/bin/flake8 mobileweb
Traceback (most recent call last):
  File ".tox/flake8/bin/flake8", line 9, in <module>
    load_entry_point('flake8', 'console_scripts', 'flake8')()
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/cli.py", line 16, in main
    app.run(argv)
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 316, in run
    self._run(argv)
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 299, in _run
    self.initialize(argv)
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 289, in initialize
    self.find_plugins()
  File "/Users/marca/dev/git-repos/flake8/src/flake8/main/application.py", line 143, in find_plugins
    self.check_plugins.load_plugins()
  File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 375, in load_plugins
    plugins = list(self.manager.map(load_plugin))
  File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 267, in map
    yield func(self.plugins[name], *args, **kwargs)
  File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 373, in load_plugin
    return plugin.load_plugin()
  File "/Users/marca/dev/git-repos/flake8/src/flake8/plugins/manager.py", line 173, in load_plugin
    raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "P999" due to Plugin <module 'teamcity.flake8_plugin' from '/Users/marca/dev/git-repos/teamcity-messages/teamcity/flake8_plugin.pyc'> is not a callable. It might be written for an older version of flake8 and might not work with this version.
```

This is nicer than the previous behavior of raising an obscure `PicklingError` and then hanging.

```
$ .tox/flake8/bin/flake8 mobileweb
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 268, in _feed
    send(obj)
PicklingError: Can't pickle <type 'module'>: attribute lookup __builtin__.module failed
```

See #164
2016-07-28 11:49:58 -07:00
Ian Cordasco
ebc7ffd4e7 Merge branch 'fix-report-ordering' into 'master'
Sort reports by line and column

*Description of changes*

The reports have been incorrectly sorted. This fixes the sorting order to use the line number and then column. It also adds a test to verify that the sorting algorithm works.

*Related to:*  #196

See merge request !100
2016-07-28 17:56:57 +00:00
Fabian Neundorf
ad3b486909 Sort reports by line and column
Originally the reports have been sorted by column and message (without the
error code), so it didn't order after the line number.

Closes #196
2016-07-28 19:25:13 +02:00
Ian Cordasco
53455fdff7 Merge branch 'bug/178' into 'master'
Match noqa for users with explanations

*Description of changes*

*Related to:*  #178

See merge request !99
2016-07-28 12:28:38 +00:00
Ian Cordasco
c0ddc54f2f
Match noqa for users with explanations
This makes the regular expression a bit more complex, and potentially
slower, but it will fix the issue where users had noqa comments with
colons followed by explanations.

Closes #178
2016-07-28 06:48:15 -05:00
Ian Cordasco
47e3e65cc1
Handle AttributeErrors during parameter aggregation
Plugins do not have their parameters checked in advance, so when we
try to aggregate parameters for a plugin, there's a chance it may
request an attribute of the FileProcessor that simply does not exist.

We catch this and re-raise it but we should also capture it in the
checker manager and handle it appropriately there as well.
2016-07-27 07:17:29 -05:00
Ian Cordasco
846bfafe6c Merge branch 'fix-mp-win-3.0' into 'master'
Fix multiprocessing on Windows

*Related to:*  #184 

I'm still running into #179 with this fix but all processes start now at least.

BTW the current design is pretty bad regarding memory footprint and bootstrap time as you have to pickle the manager object for *every* subprocess. So this does not only fix multiprocessing on Windows. It improves the multiprocessing design on other platforms, too.

See merge request !97
2016-07-27 11:43:51 +00:00
Ian Cordasco
beee924f16 Merge branch 'read_lines_crlf' into 'master'
Fix read_lines_splits_lines test for CRLF endings

This change makes the test pass for when files are saved with CRLF Windows-style line endings since those are included in various `.readlines()` methods by default.

See merge request !96
2016-07-27 11:27:12 +00:00
Ian Cordasco
d258becbe4 Merge branch '_job_count_rettype' into 'master'
_job_count always returns an int

Trivial change, but `_job_count` always returns an `int`.

See merge request !95
2016-07-27 11:26:11 +00:00
schlamar
1f10ed687e Fix multiprocessing on Windows 2016-07-27 08:09:06 +02:00
FichteFoll
ca02a8c88d Fix read_lines_splits_lines test for CRLF endings 2016-07-27 03:36:20 +02:00
Ian Cordasco
80450ff097
Ensure we're only on Python 2.7
As FichteFoll pointed out on IRC, this line could include Python 3s
less than 3.2 as well.
2016-07-26 19:55:54 -05:00
Ian Cordasco
3936141209
Update version and release notes for 3.0.2 2016-07-26 19:50:54 -05:00
Ian Cordasco
12dcb10c90
Make the documentation very obvious 2016-07-26 19:49:36 -05:00
Ian Cordasco
0e8d7cb7e2 Merge branch 'entry-point' into 'master'
Clarify what the X in the entry points does

*Description of changes*

Previously the `X` wasn't further explained in the documentation on how to
register a plugin. This plugs the hole at least for checking plugins.

*Related to:*  #183

See merge request !93
2016-07-27 00:45:31 +00:00
Ian Cordasco
e51fc5458b
Fix handling of logical lines with noqa
When attempting to centralize all inline NoQA handling in the StyleGuide
we inadvertently broke plugins relying on it in combination with checker
state. For example, the check for E402 relies both on NoQA and the state
to determine if it has seen a non-import line. Placing NoQA on the sole
line that is not an import is more elegant than placing it on each of
the following import lines.

Closes #186
2016-07-26 19:45:05 -05:00
Ian Cordasco
6eca38f2f2
Fix zero-indexed column numbering
We accidentally changed column numbering from one-indexed to
zero-indexed.
2016-07-26 19:45:05 -05:00
FichteFoll
f27d47e87e _job_count always returns an int 2016-07-27 02:01:51 +02:00
Ian Cordasco
ec6165e9d8 Merge branch 'uncap-flake8' into 'master'
Update our flake8 testenv dependencies

*Description of changes*

Uncap Flake8 and add a lower bound to flake8-import-order

*Related to:*  N/A

See merge request !94
2016-07-26 19:38:59 +00:00
Ian Cordasco
3766f3a584 Update our flake8 testenv dependencies
We had capped Flake8 until flake8-import-order created a new release. We
can now add a lower bound to flake8-import-order and uncap Flake8.
2016-07-26 19:32:49 +00:00
Ian Cordasco
c40b562feb
Move the unreleased note to the right version 2016-07-26 11:29:34 -05:00
Fabian Neundorf
9f10219137 Clarify what the X in the entry points does
Previously the `X` wasn't further explained in the documentation on how to
register a plugin. This plugs the hole at least for checking plugins.

See also: #183
2016-07-26 17:57:51 +02:00
Martin Domke
9bfdc867cd Patch print function instead of sys.stdout 2016-07-26 17:27:15 +02:00
Ian Cordasco
99602828c7 Merge branch 'bug/181' into 'master'
Fix project config file discovery

*Description of changes*

Keep searching past the current directory to find project config files.

*Related to:*  #181

See merge request !91
2016-07-26 14:40:44 +00:00
Ian Cordasco
df2fa18a08
Fix project config file discovery
Flake8 3.0 was stopping once it found the current directory but the
historical behaviour (that we didn't intend to break) searched past
that (towards root) until it found one of the project/local config
file names that could be read.

Closes #181
2016-07-26 09:37:32 -05:00
Martin Domke
c782060a06 Add --tee option to split report output stream.
The --tee option allows the linter report to be written to stdout, even
though it is being redirected to a file with the --output-file option.
This is useful if I want to store the report in a separate file for later
analysis but also be able to print the output on screen (e.g when running
in a CI environment).
2016-07-26 15:57:13 +02:00
Ian Cordasco
f82b5d62d0
Update NOQA regular expression
This allows for other text after `# noqa`.

Related to #180
2016-07-26 06:24:04 -05:00
Ian Cordasco
88d9213962
Add release notes for 3.0.1 2016-07-25 19:43:27 -05:00
Ian Cordasco
b9658eaaae Merge branch 'bug/180' into 'master'
Handle repeated --quiet options again

*Description of changes*

Handle `-q`/`--quiet` again.

*Related to:*  #180

See merge request !89
2016-07-26 00:41:08 +00:00
Ian Cordasco
222292c4b2
Handle repeated --quiet options again
Fundamentally on Flake8 2.x using -q altered the format of the errors
(and the behaviour a little) so it makes the most sense to implement
this logic with formatters rather than messy logic spread throughout
the project.

The FilenameOnly formatter will keep track of filenames already reported
and only print the name once while Nothing will print nothing.

Closes #180
2016-07-25 19:38:19 -05:00
Ian Cordasco
667a01f8df Merge branch 'bug/180' into 'master'
Wire-up --statistics again

*Description of changes*

Make `--statistics` work again

*Related to:*  #180

See merge request !87
2016-07-25 19:57:36 +00:00
Ian Cordasco
427c4b53ef Merge branch 'bug/output-file' into 'master'
Set-up and stop our formatter

*Description of changes*

Make `--output-file` work consistently (especially without verbose logging)

*Related to:*  #180

See merge request !86
2016-07-25 19:57:13 +00:00
Ian Cordasco
4dc1d11a62
Wire-up --statistics again
I'm not sure where this code went or when, but it disappeared. Let's
add it back.

Related #180
2016-07-25 14:29:09 -05:00
Ian Cordasco
559e08a09f
Set-up and stop our formatter
Without calling start and stop, our output file is not used by our
Formatters and any formatting plugins.

Related #180
2016-07-25 14:11:53 -05:00
Ian Cordasco
232ef0ed31 Merge branch 'file-plugin-docs' into 'master'
Update documentation to separate parameter types

This is the documentation update separated from !80 which should be pretty uncontroversial. I already applied the comment on the documentation here.

See merge request !83
2016-07-25 18:11:28 +00:00
Ian Cordasco
fc035c4df2 Merge branch 'bug/177' into 'master'
Handle multiline strings with '# noqa'

*Description of changes*

I had overlooked a usecase of Flake8 where people use `# noqa` at the end of a multi-line string. This addresses that oversight

*Related to:*  #177

See merge request !85
2016-07-25 16:08:16 +00:00
Ian Cordasco
299e200cb9
Handle multiline strings with '# noqa'
In Flake8 2.x we allowed people to use # noqa at the end of a multiline
string to ignore errors inside the string (e.g., E501). Being blissfully
ignorant of this, I never accounted for it in Flake8 3. This fixes the
oversight and allows multiline statements to have the # noqa at the end.

Closes #177
2016-07-25 11:00:18 -05:00
Fabian Neundorf
3191c44cfc Update documentation to separate parameter types
It updates the documentation to separate which parameters are static and
which are changed on each line. Using the latter parameters on plugins which
are only run once per file isn't very sensible.
2016-07-25 15:45:44 +02:00
Ian Cordasco
217aa8185c Merge branch 'unbreak-builds' into 'master'
Force flake8 test to below 3.x

The current version (0.8) of `flake8-import-order` still uses `parser.config_options` and so all builds fail because it installs Flake8 3.x.

Now the repository of that plugin already accounted for that but as long as it isn't released it'll cause all new builds to fail. Alternatively I can repurpose this merge request to actually enforce a newer version of `flake8-import-order` which supports Flake8 3.x.

See merge request !84
2016-07-25 12:26:25 +00:00
Fabian Neundorf
777e7e3854 Force flake8 test to below 3.x
Because flake8-import-order does not support Flake8 3.x yet, we need to force
a Flake8 version that is supported.
2016-07-25 13:53:10 +02:00
Ian Cordasco
ff0bf5f0f9
Update release notes and version string for 3.0 2016-07-24 20:11:48 -05:00
Ian Cordasco
455066cd52
Merge branch 'run-functions' 2016-07-24 20:04:59 -05:00
Ian Cordasco
5f9c0bde23
Relocate integration style checker tests 2016-07-24 20:04:48 -05:00
Fabian Neundorf
373eb15573 Support functions as file plugins too
It is possible to write plugins which are only a function. At the moment they
are called on each line manually. This allows the function also to be called
on each file once. It works similar to creating the class and calling `run` on
it immediately. The plugin function needs to return a generator.

This is based on the original comment in the `FileChecker.run_ast_checks`
method, but slightly modified as the original comment would've called the
return of the function. But the function could return the reports directly.
2016-07-24 16:27:05 +02:00