Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite63911f

Browse files
committed
Update pylama
1 parentc3ef2c4 commite63911f

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

‎ftplugin/python/pymode.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ if pymode#Option('lint')
7474
endif
7575

7676
" DESC: Run queue
77-
let &l:updatetime=g:pymode_updatetime
78-
auCursorHold<buffer>callpymode#queue#Poll()
79-
auBufLeave<buffer> Python queue.stop_queue()
77+
ifpymode#Option('lint_async')
78+
let &l:updatetime=g:pymode_updatetime
79+
auCursorHold<buffer>callpymode#queue#Poll()
80+
auBufLeave<buffer> Python queue.stop_queue()
81+
endif
8082

8183
endif
8284

‎pylibs/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=1,5,0
8+
version_info=1,5,2
99

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

‎pylibs/pylama/checkers/mccabe.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,13 @@ def get_code_complexity(code, threshold=7, filename='stdin'):
265265
complx= []
266266
McCabeChecker.max_complexity=threshold
267267
forlineno,offset,text,checkinMcCabeChecker(tree,filename).run():
268-
complx.append('%s:%d:1: %s'% (filename,lineno,text))
268+
complx.append(dict(
269+
type=McCabeChecker._code,
270+
lnum=lineno,
271+
text=text,
272+
))
269273

270-
iflen(complx)==0:
271-
return0
272-
print('\n'.join(complx))
273-
returnlen(complx)
274+
returncomplx
274275

275276

276277
defget_module_complexity(module_path,threshold=7):

‎pylibs/pylama/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def parse_options(
2323
:return argparse.Namespace:
2424
2525
"""
26+
# Parse args from command string
2627
parser=get_parser()
2728
actions=dict((a.dest,a)forainparser._actions)
2829
options=Options(
@@ -35,8 +36,10 @@ def parse_options(
3536
ifnot (argsisNone):
3637
options=parser.parse_args(args)
3738

39+
# Parse options from ini file
3840
config=get_config(str(options.options))
3941

42+
# Compile options from ini
4043
fork,vinconfig.default.items():
4144
value=getattr(options,k,_Default(None))
4245
ifnotisinstance(value,_Default):
@@ -50,6 +53,7 @@ def parse_options(
5053
value=bool(int(value))
5154
setattr(options,name,value)
5255

56+
# Postprocess options
5357
opts=dict(options.__dict__.items())
5458
forname,valueinopts.items():
5559
ifisinstance(value,_Default):
@@ -59,6 +63,7 @@ def parse_options(
5963

6064
setattr(options,name,value.value)
6165

66+
# Parse file related options
6267
options.file_params=dict()
6368
fork,sinconfig.sections.items():
6469
ifk!=config.default_section:

‎pylibs/pylama/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def shell(args=None, error=True):
2525

2626
options=parse_options(args)
2727
setup_logger(options)
28+
LOGGER.info(options)
2829

2930
# Install VSC hook
3031
ifoptions.hook:

‎pylibs/pymode/lint.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
importjson
55
importlocale
66

7+
fromosimportpathasop
78
frompylama.mainimportparse_options
89
frompylama.tasksimportcheck_path
910

@@ -20,6 +21,7 @@
2021
defcheck_file():
2122
""" Check current buffer. """
2223
buf=interface.get_current_buffer()
24+
rootpath=interface.eval_code('getcwd()')
2325

2426
async=int(interface.get_option('lint_async'))
2527
linters=interface.get_option('lint_checker')
@@ -33,15 +35,15 @@ def check_file():
3335
ifasync:
3436
add_task(
3537
run_checkers,callback=parse_result,title='Code checking',
36-
buf=buf,options=options,
38+
buf=buf,options=options,rootpath=rootpath,
3739
)
3840

3941
else:
40-
result=run_checkers(buf=buf,options=options)
42+
result=run_checkers(buf=buf,options=options,rootpath=rootpath)
4143
parse_result(result,buf=buf)
4244

4345

44-
defrun_checkers(callback=None,buf=None,options=None):
46+
defrun_checkers(callback=None,buf=None,options=None,rootpath=None):
4547
""" Run pylama code.
4648
4749
:return list: errors
@@ -50,7 +52,10 @@ def run_checkers(callback=None, buf=None, options=None):
5052
pylint_options='--rcfile={0} -r n'.format(
5153
interface.get_var('lint_config')).split()
5254

53-
returncheck_path(buf.name,options=options,pylint=pylint_options)
55+
path=buf.name
56+
ifrootpath:
57+
path=op.relpath(path,rootpath)
58+
returncheck_path(path,options=options,pylint=pylint_options)
5459

5560

5661
defparse_result(result,buf=None,**kwargs):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp