diff --git a/.gitignore b/.gitignore index 39452cd..5b84b2b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,7 @@ node_modules # bazel sucks... WORKSPACE + +# Temp/backup files +*~ + diff --git a/CMakeLists.txt b/CMakeLists.txt index 83c16f7..2f145a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,12 +13,17 @@ pkg_find(PKG eigen3 PKG fontconfig PKG freetype2 PKG fuse + PKG glib-2.0 PKG gnuradio-osmosdr PKG gnuradio-filter + PKG gtk+-3.0 + PKG gtkmm-3.0 PKG libcurl PKG libglog + PKG libpng NAMES libpng12 libpng16 PKG librtlsdr PKG libudev + PKG tinyxml2 PKG vulkan PKG x11-xcb) diff --git a/MANIFEST.in b/MANIFEST.in new file mode 120000 index 0000000..9c55e7e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +cmake_format/pypi/MANIFEST.in \ No newline at end of file diff --git a/cmake/codestyle.cmake b/cmake/codestyle.cmake index edb3b3d..d2ea906 100644 --- a/cmake/codestyle.cmake +++ b/cmake/codestyle.cmake @@ -47,7 +47,7 @@ function(format_and_lint module) list(APPEND cmake_files_ ${arg}) elseif(arg MATCHES ".*\.py") list(APPEND py_files_ ${arg}) - elseif(arg MATCHES ".*\.(cc|h)") + elseif(arg MATCHES ".*\.(c|cc|h)") list(APPEND cc_files_ ${arg}) elseif(arg MATCHES ".*\.js(\.tpl)?") list(APPEND js_files_ ${arg}) @@ -84,8 +84,12 @@ function(format_and_lint module) endif() if(py_files_) list(APPEND fmtcmds_ COMMAND autopep8 -i ${py_files_}) - list(APPEND lntcmds_ COMMAND env PYTHONPATH=${CMAKE_SOURCE_DIR} - pylint ${py_files_}) + # NOTE(josh): --rcfile= is required because some of our python files are + # note entirely within the package tree from the root of the repository. + # As such pylint will not match the rcfile in the root of the repository. + list(APPEND lntcmds_ + COMMAND env PYTHONPATH=${CMAKE_SOURCE_DIR} + pylint --rcfile=${CMAKE_SOURCE_DIR}/pylintrc ${py_files_}) # NOTE(josh): flake8 tries to use semaphores which fail in our containers # https://bugs.python.org/issue3770 (probably due to /proc/shmem or # something not being mounted) diff --git a/cmake/pkgconfig.cmake b/cmake/pkgconfig.cmake index dd52410..2d04e38 100644 --- a/cmake/pkgconfig.cmake +++ b/cmake/pkgconfig.cmake @@ -18,6 +18,7 @@ function(_pkg_query outvar arg) # Convert space-separated list to semicolon-separated cmake-list string(REGEX REPLACE " +" ";" _include_list "${_include_dirs}") + set(pkg_${outvar}_includedirs ${_include_list} CACHE STRING "include directories for ${outvar}" FORCE) @@ -30,7 +31,15 @@ function(_pkg_query outvar arg) return() endif() - set(pkg_${outvar}_cflags ${_pkg_out} CACHE STRING + # Convert space-separated list to semicolon-separated cmake-list + string(REGEX REPLACE " +" ";" _cflags "${_pkg_out}") + # Convert some C++ specific flags into a generator expression that will + # nullify during C compiles. Specifically match replace strings like + # "-std=c++11" to "$<$:-std=c++11>". + string(REGEX REPLACE "(-std=[^;]+)" "$<$:\\1>" + _cflags "${_cflags}") + + set(pkg_${outvar}_cflags ${_cflags} CACHE STRING "cflags directories for ${outvar}" FORCE) execute_process(COMMAND pkg-config --libs-only-L ${arg} diff --git a/cmake_format/__init__.py b/cmake_format/__init__.py index e3c1182..f3ec111 100644 --- a/cmake_format/__init__.py +++ b/cmake_format/__init__.py @@ -3,4 +3,4 @@ """ from __future__ import unicode_literals -VERSION = '0.5.4' +VERSION = '0.5.5' diff --git a/cmake_format/__main__.py b/cmake_format/__main__.py index 9d5649d..943ed6d 100644 --- a/cmake_format/__main__.py +++ b/cmake_format/__main__.py @@ -16,6 +16,10 @@ import argparse import collections +try: + from collections.abc import Mapping +except ImportError: + from collections import Mapping import io import json import logging @@ -173,6 +177,17 @@ def load_yaml(config_file): return out +def exec_pyconfig(configfile_path, config_dict=None): + if config_dict is None: + config_dict = {} + config_dict["__file__"] = os.path.realpath(configfile_path) + with io.open(configfile_path, 'r', encoding='utf-8') as infile: + # pylint: disable=exec-used + exec(infile.read(), config_dict) + config_dict.pop("__file__") + return config_dict + + def try_get_configdict(configfile_path): """ Try to read the configuration as yaml first, then json, then python. @@ -193,11 +208,7 @@ def try_get_configdict(configfile_path): pass try: - config_dict = {} - with io.open(configfile_path, 'r', encoding='utf-8') as infile: - # pylint: disable=exec-used - exec(infile.read(), config_dict) - return config_dict + return exec_pyconfig(configfile_path) except: # pylint: disable=bare-except pass @@ -205,40 +216,82 @@ def try_get_configdict(configfile_path): .format(configfile_path)) -def get_config(infile_path, configfile_path): +def get_config_dict(configfile_path): + """ + Return a dictionary of configuration options read from the given file path. + If the filepath has a known extension then we parse it according to that + extension. Otherwise we try to parse is using each parser one by one. + """ + if configfile_path.endswith('.json'): + with io.open(configfile_path, 'r', encoding='utf-8') as config_file: + return json.load(config_file) + + if configfile_path.endswith('.yaml'): + with io.open(configfile_path, 'r', encoding='utf-8') as config_file: + return load_yaml(config_file) + + if configfile_path.endswith('.py'): + return exec_pyconfig(configfile_path) + + return try_get_configdict(configfile_path) + + +def map_merge(output_map, increment_map): + """ + Merge `increment_map` into `output_map` recursively. + """ + for key, increment_value in increment_map.items(): + if key not in output_map: + output_map[key] = increment_value + continue + + existing_value = output_map[key] + if isinstance(existing_value, Mapping): + if isinstance(increment_value, Mapping): + map_merge(existing_value, increment_value) + else: + logger.warning( + "Cannot merge config %s of type %s into a dictionary", + key, type(increment_value)) + continue + + output_map[key] = increment_value + + return output_map + + +def get_config(infile_path, configfile_paths): """ If configfile_path is not none, then load the configuration. Otherwise search for a config file in the ancestry of the filesystem of infile_path and find a config file to load. """ - if configfile_path is None: - configfile_path = find_config_file(infile_path) - if configfile_path is not None: - configfile_path = os.path.expanduser(configfile_path) + if configfile_paths is None: + inferred_configpath = find_config_file(infile_path) + if inferred_configpath is None: + return {} + configfile_paths = [inferred_configpath] config_dict = {} - if configfile_path: - with io.open(configfile_path, 'r', encoding='utf-8') as config_file: - if configfile_path.endswith('.json'): - config_dict = json.load(config_file) - elif configfile_path.endswith('.yaml'): - config_dict = load_yaml(config_file) - elif configfile_path.endswith('.py'): - config_dict = {} - with io.open(configfile_path, 'r', encoding='utf-8') as infile: - # pylint: disable=exec-used - exec(infile.read(), config_dict) - else: - config_dict = try_get_configdict(configfile_path) + for configfile_path in configfile_paths: + configfile_path = os.path.expanduser(configfile_path) + increment_dict = get_config_dict(configfile_path) + map_merge(config_dict, increment_dict) return config_dict def yaml_odict_handler(dumper, value): + """ + Represent ordered dictionaries as yaml maps. + """ return dumper.represent_mapping(u'tag:yaml.org,2002:map', value) def yaml_register_odict(dumper): + """ + Register an order dictionary handler with the given yaml dumper + """ dumper.add_representer(collections.OrderedDict, yaml_odict_handler) @@ -367,8 +420,9 @@ def setup_argparser(arg_parser): help='Where to write the formatted file. ' 'Default is stdout.') - arg_parser.add_argument('-c', '--config-file', - help='path to configuration file') + arg_parser.add_argument( + '-c', '--config-file', '--config-files', nargs='+', + help='path to configuration file(s)') arg_parser.add_argument('infilepaths', nargs='*') add_config_options(arg_parser) @@ -455,7 +509,7 @@ def main(): newline='') else: if args.outfile_path == '-': - # NOTE(josh): The behavior or sys.stdout is different in python2 and + # NOTE(josh): The behavior of sys.stdout is different in python2 and # python3. sys.stdout is opened in 'w' mode which means that write() # takes strings in python2 and python3 and, in particular, in python3 # it does not take byte arrays. io.StreamWriter will write to diff --git a/cmake_format/doc/README.rst b/cmake_format/doc/README.rst index d1b4cd5..05f4578 100644 --- a/cmake_format/doc/README.rst +++ b/cmake_format/doc/README.rst @@ -69,8 +69,8 @@ Usage -i, --in-place -o OUTFILE_PATH, --outfile-path OUTFILE_PATH Where to write the formatted file. Default is stdout. - -c CONFIG_FILE, --config-file CONFIG_FILE - path to configuration file + -c CONFIG_FILE [CONFIG_FILE ...], --config-file CONFIG_FILE [CONFIG_FILE ...], --config-files CONFIG_FILE [CONFIG_FILE ...] + path to configuration file(s) Formatter Configuration: Override configfile options affecting general formatting diff --git a/cmake_format/doc/changelog.rst b/cmake_format/doc/changelog.rst index ed83393..5ac950b 100644 --- a/cmake_format/doc/changelog.rst +++ b/cmake_format/doc/changelog.rst @@ -6,6 +6,30 @@ Changelog v0.5 series ----------- +v0.5.5 +------ + +* Python config files now have ``__file__`` set in the global namespace +* Add parse support for ``BYPRODUCTS`` in ``add_custom_command`` +* Modify vscode extension cwd to better support subtree configuration files +* Fix vscode extension args type configuration +* Support multiple config files + +* Closes `#121`_: Support ``BYPRODUCTS`` +* Closes `#123`_: Allow multiple config files +* Closes `#125`_: Swap ordering of cwd location in vscode extension +* Closes `#128`_: Include LICENSE.txt in sdist and wheel +* Closes `#129`_: cmakeFormat.args in settings.json yields Incorrect type +* Closes `#131`_: cmakeFormat.args is an array of items of type string + +.. __#121: https://github.com/cheshirekow/cmake_format/issues/121 +.. __#123: https://github.com/cheshirekow/cmake_format/issues/123 +.. __#125: https://github.com/cheshirekow/cmake_format/issues/125 +.. __#128: https://github.com/cheshirekow/cmake_format/issues/128 +.. __#129: https://github.com/cheshirekow/cmake_format/issues/129 +.. __#131: https://github.com/cheshirekow/cmake_format/issues/131 + + v0.5.4 ------ diff --git a/cmake_format/doc/release_notes.rst b/cmake_format/doc/release_notes.rst index 940e77a..a4185dc 100644 --- a/cmake_format/doc/release_notes.rst +++ b/cmake_format/doc/release_notes.rst @@ -9,10 +9,19 @@ v0.5 series =========== ------ -v0.5.3 +v0.5.5 ------ -This is a maintanance release fixing a couple of bugs and adding some missing +This is a maintenance release fixing a few minor bugs and enhancements. One +new feature is that the ``--config`` command line option now accepts a list of +config files, which should allow for including multiple databases of command +specifications + +------ +v0.5.4 +------ + +This is a maintenance release fixing a couple of bugs and adding some missing documentation. One notable feature added is that, during in-place formatting, if the file content is unchanged ``cmake-format`` will no-longer write the file. diff --git a/cmake_format/doc/usage.rst b/cmake_format/doc/usage.rst index 5599e6a..0ecc3a6 100644 --- a/cmake_format/doc/usage.rst +++ b/cmake_format/doc/usage.rst @@ -20,7 +20,7 @@ An example configuration file is given here. Additional flags and additional kwargs will help ``cmake-format`` to break up your custom commands in a pleasant way. -.. tag: configuration-begin +.. dynamic: configuration-begin .. code:: text @@ -48,8 +48,13 @@ pleasant way. dangle_parens = False # If the statement spelling length (including space and parenthesis is larger - # than the tab width by more than this amoung, then force vertical nesting - nest_threshold = 2 + # than the tab width by more than this amoung, then force reject un-nested + # layouts. + max_prefix_chars = 2 + + # If a candidate layout is wrapped horizontally but it exceeds this many lines, + # then reject the layout. + max_lines_hwrap = 2 # What style line endings to use in the output. line_ending = 'unix' @@ -77,6 +82,10 @@ pleasant way. # If true, the argument lists which are known to be sortable will be sorted # lexicographicall + enable_sort = True + + # If true, the parsers may infer whether or not an argument list is sortable + # (without annotation). autosort = False # If a comment line starts with at least this many consecutive hash characters, @@ -101,13 +110,13 @@ pleasant way. # enable comment markup parsing and reflow enable_markup = True - # If comment markup is enabled, don't reflow the first comment block in - # eachlistfile. Use this to preserve formatting of your - # copyright/licensestatements. + # If comment markup is enabled, don't reflow the first comment block in each + # listfile. Use this to preserve formatting of your copyright/license + # statements. first_comment_is_literal = False - # If comment markup is enabled, don't reflow any comment block which matchesthis - # (regex) pattern. Default is `None` (disabled). + # If comment markup is enabled, don't reflow any comment block which matches + # this (regex) pattern. Default is `None` (disabled). literal_comment_pattern = None # Regular expression to match preformat fences in comments @@ -137,7 +146,7 @@ pleasant way. output_encoding = 'utf-8' -.. tag: configuration-end +.. dynamic: configuration-end You may specify a path to a configuration file with the ``--config-file`` command line option. Otherwise, ``cmake-format`` will search the ancestry @@ -158,7 +167,7 @@ Usage ----- -.. tag: usage-begin +.. dynamic: usage-begin .. code:: text @@ -186,6 +195,7 @@ Usage optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit + -l {error,warning,info,debug}, --log-level {error,warning,info,debug} --dump-config [{yaml,json,python}] If specified, print the default configuration to stdout and exit @@ -193,8 +203,8 @@ Usage -i, --in-place -o OUTFILE_PATH, --outfile-path OUTFILE_PATH Where to write the formatted file. Default is stdout. - -c CONFIG_FILE, --config-file CONFIG_FILE - path to configuration file + -c CONFIG_FILE [CONFIG_FILE ...], --config-file CONFIG_FILE [CONFIG_FILE ...], --config-files CONFIG_FILE [CONFIG_FILE ...] + path to configuration file(s) Formatter Configuration: Override configfile options affecting general formatting @@ -213,10 +223,13 @@ Usage --dangle-parens [DANGLE_PARENS] If a statement is wrapped to more than one line, than dangle the closing parenthesis on it's own line - --nest-threshold NEST_THRESHOLD + --max-prefix-chars MAX_PREFIX_CHARS If the statement spelling length (including space and parenthesis is larger than the tab width by more than - this amoung, then force vertical nesting + this amoung, then force reject un-nested layouts. + --max-lines-hwrap MAX_LINES_HWRAP + If a candidate layout is wrapped horizontally but it + exceeds this many lines, then reject the layout. --line-ending {windows,unix,auto} What style line endings to use in the output. --command-case {lower,upper,canonical,unchanged} @@ -230,9 +243,12 @@ Usage --algorithm-order [ALGORITHM_ORDER [ALGORITHM_ORDER ...]] Specify the order of wrapping algorithms during successive reflow attempts - --autosort [AUTOSORT] + --enable-sort [ENABLE_SORT] If true, the argument lists which are known to be sortable will be sorted lexicographicall + --autosort [AUTOSORT] + If true, the parsers may infer whether or not an + argument list is sortable (without annotation). --hashruler-min-length HASHRULER_MIN_LENGTH If a comment line starts with at least this many consecutive hash characters, then don't lstrip() them @@ -251,11 +267,11 @@ Usage enable comment markup parsing and reflow --first-comment-is-literal [FIRST_COMMENT_IS_LITERAL] If comment markup is enabled, don't reflow the first - comment block in eachlistfile. Use this to preserve - formatting of your copyright/licensestatements. + comment block in each listfile. Use this to preserve + formatting of your copyright/license statements. --literal-comment-pattern LITERAL_COMMENT_PATTERN If comment markup is enabled, don't reflow any comment - block which matchesthis (regex) pattern. Default is + block which matches this (regex) pattern. Default is `None` (disabled). --fence-pattern FENCE_PATTERN Regular expression to match preformat fences in @@ -282,4 +298,4 @@ Usage utf-8. Note that cmake only claims to support utf-8 so be careful when using anything else -.. tag: usage-end +.. dynamic: usage-end diff --git a/cmake_format/invocation_tests.py b/cmake_format/invocation_tests.py index 2ce82aa..2dc638a 100644 --- a/cmake_format/invocation_tests.py +++ b/cmake_format/invocation_tests.py @@ -223,6 +223,34 @@ def test_no_config_invocation(self): if delta_lines: raise AssertionError('\n'.join(delta_lines[2:])) + def test_multiple_config_invocation(self): + """ + Repeat the default config test using a config file that is split. The + custom command definitions are in the second file. + """ + thisdir = os.path.realpath(os.path.dirname(__file__)) + configdir = os.path.join(thisdir, 'test') + infile_path = os.path.join(thisdir, 'test', 'test_in.cmake') + expectfile_path = os.path.join(thisdir, 'test', 'test_out.cmake') + + subprocess.check_call([ + sys.executable, '-Bm', 'cmake_format', '-c', + os.path.join(configdir, 'cmake-format-split-1.py'), + os.path.join(configdir, 'cmake-format-split-2.py'), + '-o', os.path.join(self.tempdir, 'test_out.cmake'), + infile_path], cwd=self.tempdir, env=self.env) + + with io.open(os.path.join(self.tempdir, 'test_out.cmake'), 'r', + encoding='utf8') as infile: + actual_text = infile.read() + with io.open(expectfile_path, 'r', encoding='utf8') as infile: + expected_text = infile.read() + + delta_lines = list(difflib.unified_diff(expected_text.split('\n'), + actual_text.split('\n'))) + if delta_lines: + raise AssertionError('\n'.join(delta_lines[2:])) + def test_auto_lineendings(self): """ Verify that windows line-endings are detected and preserved on input. diff --git a/cmake_format/parse_funs/add_xxx.py b/cmake_format/parse_funs/add_xxx.py index 6f68ce4..81bd5b5 100644 --- a/cmake_format/parse_funs/add_xxx.py +++ b/cmake_format/parse_funs/add_xxx.py @@ -14,15 +14,17 @@ def parse_add_custom_command(tokens, breakstack): """ :: - add_custom_command(OUTPUT output1 [output2 ...] - COMMAND command1 [ARGS] [args1...] - [COMMAND command2 [ARGS] [args2...] ...] - [MAIN_DEPENDENCY depend] - [DEPENDS [depends...]] - [IMPLICIT_DEPENDS depend1 - [ depend2] ...] - [WORKING_DIRECTORY dir] - [COMMENT comment] [VERBATIM] [APPEND]) + add_custom_command(OUTPUT output1 [output2 ...] + COMMAND command1 [ARGS] [args1...] + [COMMAND command2 [ARGS] [args2...] ...] + [MAIN_DEPENDENCY depend] + [DEPENDS [depends...]] + [BYPRODUCTS [files...]] + [IMPLICIT_DEPENDS depend1 + [ depend2] ...] + [WORKING_DIRECTORY dir] + [COMMENT comment] + [VERBATIM] [APPEND] [USES_TERMINAL]) :see: https://cmake.org/cmake/help/v3.0/command/add_custom_command.html """ @@ -30,6 +32,7 @@ def parse_add_custom_command(tokens, breakstack): tokens, npargs='*', kwargs={ + "BYPRODUCTS": PositionalParser('*'), "COMMAND": parse_shell_command, "COMMENT": PositionalParser('*'), "DEPENDS": PositionalParser('*'), @@ -38,7 +41,7 @@ def parse_add_custom_command(tokens, breakstack): "OUTPUT": PositionalParser('+'), "WORKING_DIRECTORY": PositionalParser(1) }, - flags=["APPEND", "VERBATIM", + flags=["APPEND", "VERBATIM", "USES_TERMINAL", "PRE_BUILD", "PRE_LINK", "POST_BUILD"], breakstack=breakstack) diff --git a/cmake_format/pypi/MANIFEST.in b/cmake_format/pypi/MANIFEST.in new file mode 100644 index 0000000..3dd1075 --- /dev/null +++ b/cmake_format/pypi/MANIFEST.in @@ -0,0 +1,4 @@ +prune doc/ +prune cmake_format/pypi +prune cmake_format/doc +include LICENSE diff --git a/cmake_format/pypi/setup.py b/cmake_format/pypi/setup.py index 5029c3c..2175390 100644 --- a/cmake_format/pypi/setup.py +++ b/cmake_format/pypi/setup.py @@ -31,7 +31,13 @@ url=GITHUB_URL, download_url='{}/archive/{}.tar.gz'.format(GITHUB_URL, VERSION), keywords=['cmake', 'format'], - classifiers=[], + license="GPLv3", + classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)" + ], + include_package_data=True, entry_points={ 'console_scripts': [ 'cmake-format=cmake_format.__main__:main', diff --git a/cmake_format/test/cmake-format-split-1.py b/cmake_format/test/cmake-format-split-1.py new file mode 100644 index 0000000..d22ce1d --- /dev/null +++ b/cmake_format/test/cmake-format-split-1.py @@ -0,0 +1,14 @@ +# How wide to allow formatted cmake files +line_width = 80 + +# How many spaces to tab for indent +tab_size = 2 + +# If arglists are longer than this, break them always. +max_subargs_per_line = 3 + +# If true, separate control flow names from the parentheses with a space +separate_ctrl_name_with_space = False + +# If true, separate function names from the parenthesis with a space +separate_fn_name_with_space = False diff --git a/cmake_format/test/cmake-format-split-2.py b/cmake_format/test/cmake-format-split-2.py new file mode 100644 index 0000000..85b26a1 --- /dev/null +++ b/cmake_format/test/cmake-format-split-2.py @@ -0,0 +1,11 @@ +# Additional FLAGS and KWARGS for custom commands +additional_commands = { + "foo": { + "flags": ["BAR", "BAZ"], + "kwargs": { + "HEADERS": '*', + "SOURCES": '*', + "DEPENDS": '*', + } + } +} diff --git a/cmake_format/vscode_extension/package.json b/cmake_format/vscode_extension/package.json index fb45a48..6b538e8 100644 --- a/cmake_format/vscode_extension/package.json +++ b/cmake_format/vscode_extension/package.json @@ -2,7 +2,7 @@ "name": "cmake-format", "displayName": "cmake-format", "description": "Format listfiles so they don't look like crap", - "version": "0.4.2", + "version": "0.5.5", "publisher": "cheshirekow", "repository": "https://github.com/cheshirekow/cmake_format", "icon": "images/cmake-format-logo.png", @@ -61,7 +61,10 @@ "description": "Full path cmake-format entry point script or binary" }, "cmakeFormat.args": { - "type": "array[string]", + "type": "array", + "items": { + "type": "string" + }, "default": [], "description": "Additional arguments to pass to cmake-format. Specify, e.g. --config-file here." } diff --git a/cmake_format/vscode_extension/src/extension.ts b/cmake_format/vscode_extension/src/extension.ts index e91c605..4e5ec28 100644 --- a/cmake_format/vscode_extension/src/extension.ts +++ b/cmake_format/vscode_extension/src/extension.ts @@ -27,6 +27,10 @@ export function activate(context: vscode.ExtensionContext) { }; var cwd = config.get("cwd"); + if (cwd == null && document.uri.fsPath != null) { + cwd = path.dirname(document.uri.fsPath) + console.log("No cwd configured, using: " + cwd); + } if (cwd == null) { var folder = vscode.workspace.getWorkspaceFolder(document.uri); if (folder != null) { @@ -34,10 +38,7 @@ export function activate(context: vscode.ExtensionContext) { console.log("No cwd configured, using workspace path: " + cwd); } } - if (cwd == null && document.uri.fsPath != null) { - cwd = path.dirname(document.uri.fsPath) - console.log("No cwd configured, no workspace path, using: " + cwd); - } + if (cwd != null && fs.statSync(cwd).isDirectory()) { opts["cwd"] = cwd; } else { @@ -84,4 +85,4 @@ export function activate(context: vscode.ExtensionContext) { } export function deactivate() { -} \ No newline at end of file +} diff --git a/pylintrc b/pylintrc index d0224df..c68eb18 100644 --- a/pylintrc +++ b/pylintrc @@ -54,6 +54,7 @@ disable= missing-docstring, no-name-in-module, no-self-use, + similarities, star-args, too-few-public-methods, too-many-ancestors, diff --git a/requirements.txt b/requirements.txt index 2373925..6a4bb99 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +astroid==2.2.5; python_version >= '3.0' autopep8==1.3.5; python_version < '3.0' autopep8==1.4.3; python_version >= '3.0' flake8==3.6.0; python_version < '3.0'