mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 05:54:17 +00:00
Merged in fr710/flake8 (pull request #41)
Fix Git and Mercurial hooks if no config files are present
This commit is contained in:
commit
89f0800682
1 changed files with 5 additions and 10 deletions
|
|
@ -49,11 +49,8 @@ def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
|
||||||
|
|
||||||
files_modified = [f for f in files_modified if f.endswith('.py')]
|
files_modified = [f for f in files_modified if f.endswith('.py')]
|
||||||
|
|
||||||
flake8_style = get_style_guide(
|
flake8_style = get_style_guide(config_file=DEFAULT_CONFIG, paths=['.'],
|
||||||
parse_argv=True,
|
**options)
|
||||||
config_file=DEFAULT_CONFIG,
|
|
||||||
**options
|
|
||||||
)
|
|
||||||
|
|
||||||
# Copy staged versions to temporary directory
|
# Copy staged versions to temporary directory
|
||||||
tmpdir = mkdtemp()
|
tmpdir = mkdtemp()
|
||||||
|
|
@ -97,9 +94,7 @@ def hg_hook(ui, repo, **kwargs):
|
||||||
complexity = ui.config('flake8', 'complexity', default=-1)
|
complexity = ui.config('flake8', 'complexity', default=-1)
|
||||||
strict = ui.configbool('flake8', 'strict', default=True)
|
strict = ui.configbool('flake8', 'strict', default=True)
|
||||||
ignore = ui.config('flake8', 'ignore', default=None)
|
ignore = ui.config('flake8', 'ignore', default=None)
|
||||||
config = ui.config('flake8', 'config', default=True)
|
config = ui.config('flake8', 'config', default=DEFAULT_CONFIG)
|
||||||
if config is True:
|
|
||||||
config = DEFAULT_CONFIG
|
|
||||||
|
|
||||||
paths = _get_files(repo, **kwargs)
|
paths = _get_files(repo, **kwargs)
|
||||||
|
|
||||||
|
|
@ -111,7 +106,7 @@ def hg_hook(ui, repo, **kwargs):
|
||||||
if complexity > -1:
|
if complexity > -1:
|
||||||
options['max_complexity'] = complexity
|
options['max_complexity'] = complexity
|
||||||
|
|
||||||
flake8_style = get_style_guide(parse_argv=True, config_file=config,
|
flake8_style = get_style_guide(config_file=config, paths=['.'],
|
||||||
**options)
|
**options)
|
||||||
report = flake8_style.check_files(paths)
|
report = flake8_style.check_files(paths)
|
||||||
|
|
||||||
|
|
@ -211,7 +206,7 @@ def _install_hg_hook(path):
|
||||||
c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False))
|
c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False))
|
||||||
|
|
||||||
if not c.has_option('flake8', 'ignore'):
|
if not c.has_option('flake8', 'ignore'):
|
||||||
c.set('flake8', 'ignore', os.getenv('FLAKE8_IGNORE'))
|
c.set('flake8', 'ignore', os.getenv('FLAKE8_IGNORE', ''))
|
||||||
|
|
||||||
if not c.has_option('flake8', 'lazy'):
|
if not c.has_option('flake8', 'lazy'):
|
||||||
c.set('flake8', 'lazy', os.getenv('FLAKE8_LAZY', False))
|
c.set('flake8', 'lazy', os.getenv('FLAKE8_LAZY', False))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue