pax_global_header00006660000000000000000000000064140474506110014514gustar00rootroot0000000000000052 comment=7ddf412541da6b1c9b3073468ad7705077ef04a5 pyls-isort-0.2.2/000077500000000000000000000000001404745061100136425ustar00rootroot00000000000000pyls-isort-0.2.2/.gitignore000066400000000000000000000000141404745061100156250ustar00rootroot00000000000000.env build/ pyls-isort-0.2.2/.style.yapf000066400000000000000000000134301404745061100157420ustar00rootroot00000000000000[style] based_on_style = pep8 # █████ ██ ██ # ██ ██ ██ ██ # ███████ ██ ██ # ██ ██ ██ ██ # ██ ██ ███████ ███████ # Align closing bracket with visual indentation. # align_closing_bracket_with_visual_indent=True # Allow dictionary keys to exist on multiple lines. For example: # # x = { # ('this is the first element of a tuple', # 'this is the second element of a tuple'): # value, # } # allow_multiline_dictionary_keys=False # Allow lambdas to be formatted on more than one line. # allow_multiline_lambdas=False # Insert a blank line before a class-level docstring. # blank_line_before_class_docstring=False # Insert a blank line before a 'def' or 'class' immediately nested # within another 'def' or 'class'. For example: # # class Foo: # # <------ this blank line # def method(): # ... # blank_line_before_nested_class_or_def=False # Do not split consecutive brackets. Only relevant when # dedent_closing_brackets is set. For example: # # call_func_that_takes_a_dict( # { # 'key1': 'value1', # 'key2': 'value2', # } # ) # # would reformat to: # # call_func_that_takes_a_dict({ # 'key1': 'value1', # 'key2': 'value2', # }) coalesce_brackets=True # The column limit. # column_limit=79 # Indent width used for line continuations. # continuation_indent_width=4 # Put closing brackets on a separate line, dedented, if the bracketed # expression can't fit in a single line. Applies to all kinds of brackets, # including function definitions and calls. For example: # # config = { # 'key1': 'value1', # 'key2': 'value2', # } # <--- this bracket is dedented and on a separate line # # time_series = self.remote_client.query_entity_counters( # entity='dev3246.region1', # key='dns.query_latency_tcp', # transform=Transformation.AVERAGE(window=timedelta(seconds=60)), # start_ts=now()-timedelta(days=3), # end_ts=now(), # ) # <--- this bracket is dedented and on a separate line dedent_closing_brackets=True # Place each dictionary entry onto its own line. # each_dict_entry_on_separate_line=True # The regex for an i18n comment. The presence of this comment stops # reformatting of that line, because the comments are required to be # next to the string they translate. # i18n_comment= # The i18n function call names. The presence of this function stops # reformattting on that line, because the string it has cannot be moved # away from the i18n comment. # i18n_function_call= # Indent the dictionary value if it cannot fit on the same line as the # dictionary key. For example: # # config = { # 'key1': # 'value1', # 'key2': value1 + # value2, # } indent_dictionary_value=True # The number of columns to use for indentation. # indent_width=4 # Join short lines into one line. E.g., single line 'if' statements. join_multiple_lines=False # Do not include spaces around selected binary operators. For example: # # 1 + 2 * 3 - 4 / 5 # # will be formatted as follows when configured with a value "*,/": # # 1 + 2*3 - 4/5 # # no_spaces_around_selected_binary_operators=set() # Use spaces around default or named assigns. # spaces_around_default_or_named_assign=False # Use spaces around the power operator. # spaces_around_power_operator=False # The number of spaces required before a trailing comment. # spaces_before_comment=2 # Insert a space between the ending comma and closing bracket of a list, # etc. # space_between_ending_comma_and_closing_bracket=True # Split before arguments if the argument list is terminated by a # comma. # split_arguments_when_comma_terminated=False # Set to True to prefer splitting before '&', '|' or '^' rather than # after. # split_before_bitwise_operator=True # Split before a dictionary or set generator (comp_for). For example, note # the split before the 'for': # # foo = { # variable: 'Hello world, have a nice day!' # for variable in bar if variable != 42 # } # split_before_dict_set_generator=True # If an argument / parameter list is going to be split, then split before # the first argument. split_before_first_argument=True # Set to True to prefer splitting before 'and' or 'or' rather than # after. # split_before_logical_operator=True # Split named assignments onto individual lines. # split_before_named_assigns=True # The penalty for splitting right after the opening bracket. # split_penalty_after_opening_bracket=30 # The penalty for splitting the line after a unary operator. # split_penalty_after_unary_operator=10000 # The penalty for splitting right before an if expression. # split_penalty_before_if_expr=0 # The penalty of splitting the line around the '&', '|', and '^' # operators. # split_penalty_bitwise_operator=300 # The penalty for characters over the column limit. # split_penalty_excess_character=4500 # The penalty incurred by adding a line split to the unwrapped line. The # more line splits added the higher the penalty. # split_penalty_for_added_line_split=30 # The penalty of splitting a list of "import as" names. For example: # # from a_very_long_or_indented_module_name_yada_yad import (long_argument_1, # long_argument_2, # long_argument_3) # # would reformat to something like: # # from a_very_long_or_indented_module_name_yada_yad import ( # long_argument_1, long_argument_2, long_argument_3) # split_penalty_import_names=0 # The penalty of splitting the line around the 'and' and 'or' # operators. # split_penalty_logical_operator=300 # Use the Tab character for indentation. # use_tabs=False pyls-isort-0.2.2/LICENSE000066400000000000000000000020671404745061100146540ustar00rootroot00000000000000The MIT License (MIT) Copyright 2018 Florian Mounier. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pyls-isort-0.2.2/Makefile000066400000000000000000000010321404745061100152760ustar00rootroot00000000000000include Makefile.config -include Makefile.custom.config all: install check-outdated install: test -d $(VENV) || virtualenv $(VENV) $(PIP) install --upgrade --no-cache pip setuptools -e . devcore clean: rm -fr $(VENV) rm -fr *.egg-info check-outdated: $(PIP) list --outdated --format=columns release: git pull $(eval VERSION := $(shell PROJECT_NAME=$(PROJECT_NAME) $(VENV)/bin/devcore bump $(LEVEL))) git commit -am "Bump $(VERSION)" git tag $(VERSION) $(PYTHON) setup.py sdist bdist_wheel upload git push git push --tags pyls-isort-0.2.2/Makefile.config000066400000000000000000000001641404745061100165470ustar00rootroot00000000000000export PROJECT_NAME = pyls_isort # Python env VENV = $(PWD)/.env PIP = $(VENV)/bin/pip PYTHON = $(VENV)/bin/python pyls-isort-0.2.2/README.md000066400000000000000000000003071404745061100151210ustar00rootroot00000000000000# pyls-isort Isort plugin for [python-lsp-server](https://github.com/python-lsp/python-lsp-server). Sort your imports when formatting your code with [isort](http://isort.readthedocs.io/en/latest/). pyls-isort-0.2.2/pyls_isort/000077500000000000000000000000001404745061100160515ustar00rootroot00000000000000pyls-isort-0.2.2/pyls_isort/__about__.py000066400000000000000000000004471404745061100203360ustar00rootroot00000000000000__title__ = "pyls-isort" __version__ = "0.2.2" __summary__ = "Isort plugin for python-lsp-server" __uri__ = "https://github.com/paradoxxxzero/pyls-isort" __author__ = "Florian Mounier" __email__ = "paradoxxx.zero@gmail.com" __license__ = "MIT" __copyright__ = "Copyright 2017 %s" % __author__ pyls-isort-0.2.2/pyls_isort/__init__.py000066400000000000000000000000541404745061100201610ustar00rootroot00000000000000from .__about__ import * # noqa: F401,F403 pyls-isort-0.2.2/pyls_isort/plugin.py000066400000000000000000000031211404745061100177160ustar00rootroot00000000000000import os try: # isort<5 from isort import SortImports def isort_sort(source, settings_path): return SortImports( file_contents=source, settings_path=settings_path, ).output except ImportError: # isort=>5 from isort import code from isort.settings import Config def isort_sort(source, settings_path): return code(source, config=Config(settings_path=settings_path)) from pylsp import hookimpl def sort(document, override=None): source = override or document.source sorted_source = isort_sort( source, os.path.dirname(os.path.abspath(document.path)), ) if source == sorted_source: return return [{ 'range': { 'start': { 'line': 0, 'character': 0, }, 'end': { 'line': len(document.lines), 'character': 0, }, }, 'newText': sorted_source, }] @hookimpl(hookwrapper=True) def pylsp_format_document(document): outcome = yield results = outcome.get_result() if results: newResults = sort(document, results[0]['newText']) else: newResults = sort(document) if newResults: outcome.force_result(newResults) @hookimpl(hookwrapper=True) def pylsp_format_range(document, range): outcome = yield results = outcome.get_result() if results: newResults = sort(document, results[0]['newText']) else: newResults = sort(document) if newResults: outcome.force_result(newResults) pyls-isort-0.2.2/setup.py000077500000000000000000000012471404745061100153630ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- import os from setuptools import find_packages, setup about = {} with open(os.path.join(os.path.dirname(__file__), "pyls_isort", "__about__.py")) as f: exec(f.read(), about) setup( name=about["__title__"], version=about["__version__"], description=about["__summary__"], url=about["__uri__"], author=about["__author__"], author_email=about["__email__"], license=about["__license__"], platforms="Any", packages=find_packages(), provides=["pyls_isort"], install_requires=["python-lsp-server", "isort"], entry_points={ "pylsp": ["pyls_isort = pyls_isort.plugin"], }, )