diff options
author | Timothy Edmund Crosley <timothy.crosley@gmail.com> | 2019-02-17 18:40:45 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-17 18:40:45 -0800 |
commit | aed6f858e15e6f13299790b89fd090648d78d0a9 (patch) | |
tree | 74bd231637409e616f37552a90b8b86631edfa08 | |
parent | 880f6798ee1bb5ed81779217ce45f221f0e50c06 (diff) | |
parent | 397b6443eac022294e180b7ca714403417855df7 (diff) | |
download | isort-aed6f858e15e6f13299790b89fd090648d78d0a9.tar.gz |
Merge pull request #777 from jinmel/develop
Add option to ignore trailing comments
-rw-r--r-- | isort/isort.py | 12 | ||||
-rw-r--r-- | isort/settings.py | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/isort/isort.py b/isort/isort.py index 9c7ed8cf..970117f1 100644 --- a/isort/isort.py +++ b/isort/isort.py @@ -278,11 +278,15 @@ class SortImports(object): def _add_comments(self, comments, original_string=""): """ - Returns a string with comments added + Returns a string with comments added if ignore_comments is not set. """ - return comments and "{0}{1} {2}".format(self._strip_comments(original_string)[0], - self.config['comment_prefix'], - "; ".join(comments)) or original_string + + if not self.config['ignore_comments']: + return comments and "{0}{1} {2}".format(self._strip_comments(original_string)[0], + self.config['comment_prefix'], + "; ".join(comments)) or original_string + + return comments and self._strip_comments(original_string)[0] def _wrap(self, line): """ diff --git a/isort/settings.py b/isort/settings.py index 8d6be959..f6ef1c25 100644 --- a/isort/settings.py +++ b/isort/settings.py @@ -152,8 +152,8 @@ default = {'force_to_top': [], 'ignore_whitespace': False, 'no_lines_before': [], 'no_inline_sort': False, - 'safety_excludes': True, - } + 'ignore_comments': False, + 'safety_excludes': True} @lru_cache() |