Skip to content

Commit 26bba03

Browse files
committed
Merge branch 'release/0.7.1b'
2 parents 4f4ecbd + df0d73d commit 26bba03

File tree

171 files changed

+185
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+185
-96
lines changed

Changelog.rst

Lines changed: 1 addition & 1 deletion

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
PYMODE = $(CURDIR)/pymode
2+
LIBS = $(PYMODE)/libs
3+
PYLAMA = $(LIBS)/pylama
4+
15
.PHONY: clean
26
clean:
37
find . -name "*.pyc" -delete
@@ -9,6 +13,12 @@ test:
913

1014
.PHONY: pylama
1115
pylama:
12-
rm -rf pylibs/pylama
13-
cp -r ~/Dropbox/projects/pylama/pylama pylibs/pylama
14-
cp -r ~/Dropbox/projects/pylama/plugins/pylama_pylint/pylama_pylint/ pylibs/pylama/lint/pylama_pylint
16+
rm -rf $(PYLAMA)
17+
make $(PYLAMA)
18+
make $(PYLAMA)/lint/pylama_pylint
19+
20+
$(PYLAMA):
21+
cp -r ~/Dropbox/projects/pylama/pylama $(PYLAMA)
22+
23+
$(PYLAMA)/lint/pylama_pylint:
24+
cp -r ~/Dropbox/projects/pylama/plugins/pylama_pylint/pylama_pylint/ $(PYLAMA)/lint/pylama_pylint

autoload/pymode/lint.vim

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ fun! pymode#lint#check() "{{{
4646

4747
let b:pymode_errors = {}
4848

49-
if !pymode#save()
50-
return 0
51-
endif
52-
5349
call pymode#wide_message('Code checking is running ...')
5450

5551
PymodePython code_check()

doc/pymode.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____) ~
77

88

9-
Version: 0.7.0b
9+
Version: 0.7.1b
1010

1111
==============================================================================
1212
CONTENTS *pymode-contents*

ftplugin/python/pymode.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ if !pymode#default('g:pymode_init', 1)
77
call pymode#init(expand('<sfile>:p:h:h:h'), g:pymode_paths)
88
call pymode#virtualenv#init()
99
call pymode#breakpoint#init()
10+
PymodePython from pymode.utils import patch_paths
11+
PymodePython patch_paths()
1012
endif
1113

1214
augroup pymode

plugin/pymode.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" vi: fdl=1
2-
let g:pymode_version = "0.7.0b"
2+
let g:pymode_version = "0.7.1b"
33

44
com! PymodeVersion echomsg "Current python-mode version: " . g:pymode_version
55
com! PymodeTroubleshooting call pymode#troubleshooting#test()

pymode/pylama/__init__.py renamed to pymode/libs/pylama/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
"""
77

8-
version_info = 2, 0, 1
8+
version_info = 2, 0, 3
99

1010
__version__ = version = '.'.join(map(str, version_info))
1111
__project__ = __name__

pymode/pylama/config.py renamed to pymode/libs/pylama/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from . import version
1010
from .core import LOGGER, STREAM
11-
from .inirama import Namespace
12-
from .lint import LINTERS
11+
from .libs.inirama import Namespace
12+
from .lint.extensions import LINTERS
1313

1414

1515
#: A default checkers
@@ -127,6 +127,8 @@ def parse_linters(csp_str):
127127
linter = LINTERS.get(name)
128128
if linter:
129129
result.append((name, linter))
130+
else:
131+
logging.warn("Linter `%s` not found." % name)
130132
return result
131133

132134
parser.add_argument(

pymode/pylama/core.py renamed to pymode/libs/pylama/core.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
import logging
77
import re
8-
from .lint import LINTERS
8+
from .lint.extensions import LINTERS
99

1010
#: The skip pattern
1111
SKIP_PATTERN = re.compile(r'# *noqa\b', re.I).search
@@ -20,7 +20,9 @@
2020
LOGGER.addHandler(STREAM)
2121

2222

23-
def run(path, ignore=None, select=None, linters=None, config=None, **meta):
23+
def run(
24+
path, ignore=None, select=None, linters=None, config=None, code=None,
25+
**meta):
2426
""" Run a code checkers with given params.
2527
2628
:return errors: list of dictionaries with error's information
@@ -29,11 +31,9 @@ def run(path, ignore=None, select=None, linters=None, config=None, **meta):
2931
errors = []
3032
linters = linters or LINTERS.items()
3133
params = dict(ignore=ignore, select=select)
32-
code = None
3334
try:
34-
with open(path, 'rU') as f:
35-
code = f.read() + '\n\n'
36-
35+
with CodeContext(code, path) as ctx:
36+
code = ctx.code
3737
params = prepare_params(
3838
parse_modeline(code), config, ignore=ignore, select=select
3939
)
@@ -78,7 +78,7 @@ def run(path, ignore=None, select=None, linters=None, config=None, **meta):
7878

7979
errors = [er for er in errors if filter_errors(er, **params)]
8080

81-
if code:
81+
if code and errors:
8282
errors = filter_skiplines(code, errors)
8383

8484
return sorted(errors, key=lambda x: x['lnum'])
@@ -158,3 +158,23 @@ def filter_skiplines(code, errors):
158158
errors = [er for er in errors if not er['lnum'] in removed]
159159

160160
return errors
161+
162+
163+
class CodeContext(object):
164+
165+
""" Read file if code is None. """
166+
167+
def __init__(self, code, path):
168+
self.code = code
169+
self.path = path
170+
self._file = None
171+
172+
def __enter__(self):
173+
if self.code is None:
174+
self._file = open(self.path, 'rU')
175+
self.code = self._file.read() + '\n\n'
176+
return self
177+
178+
def __exit__(self):
179+
if not self._file is None:
180+
self._file.close()

pymode/pylama/hook.py renamed to pymode/libs/pylama/hook.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ def run(command):
2929

3030
def git_hook():
3131
""" Run pylama after git commit. """
32-
3332
from .main import check_files
33+
3434
_, files_modified, _ = run("git diff-index --cached --name-only HEAD")
3535

3636
options = parse_options()
3737
setup_logger(options)
38-
check_files(
39-
[f for f in map(str, files_modified) if f.endswith('.py')], options
40-
)
38+
check_files([f for f in map(str, files_modified)], options)
4139

4240

4341
def hg_hook(ui, repo, node=None, **kwargs):
@@ -53,8 +51,7 @@ def hg_hook(ui, repo, node=None, **kwargs):
5351
if file_ in seen or not op.exists(file_):
5452
continue
5553
seen.add(file_)
56-
if file_.endswith('.py'):
57-
paths.append(file_)
54+
paths.append(file_)
5855

5956
options = parse_options()
6057
setup_logger(options)

0 commit comments

Comments
 (0)