PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.52k stars 582 forks source link

Issue with black when an import is almost 88 characters #1481

Closed yajo closed 4 years ago

yajo commented 4 years ago

I have this import:

from odoo.addons.base_external_dbsource_importer.models.base_external_dbsource import BaseExternalModelImporter

Black 20.8b1 converts it to this, putting the ( character exactly at length 88:

from odoo.addons.base_external_dbsource_importer.models.base_external_dbsource import (
    BaseExternalModelImporter,
)

Isort 5.5.2 converts it to this, putting the \ character exactly at length 88:

from odoo.addons.base_external_dbsource_importer.models.base_external_dbsource import \
    BaseExternalModelImporter

.isort.cfg:

[settings]
; see https://github.com/psf/black
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
use_parentheses=True
line_length=88
known_odoo=odoo
known_odoo_addons=odoo.addons
sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER
default_section=THIRDPARTY
yajo commented 4 years ago

I think I found the problem, and it's not that there's some incompatibility.

It seems like isort doesn't properly seek for the config file in folders upper than the file passed. Check this terminal session, where I have a properly-placed .isort.cfg file that indicates several settings (example: line_length=88) but when I pass a direct path to a file to be reformatted, it doesn't detect that file (gets line_length=79) unless I add --settings .:

```bash yajo@toolbox:~/p/myproject-odoo|BOT-autoupdate⚡* ➤ cat .isort.cfg [settings] ; see https://github.com/psf/black multi_line_output=3 include_trailing_comma=True force_grid_wrap=0 combine_as_imports=True use_parentheses=True line_length=88 known_odoo=odoo known_odoo_addons=odoo.addons sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER default_section=THIRDPARTY yajo@toolbox:~/p/myproject-odoo|BOT-autoupdate⚡* ➤ pipx run isort --version _ _ (_) ___ ___ _ __| |_ | |/ _/ / _ \/ '__ _/ | |\__ \/\_\/| | | |_ |_|\___/\___/\_/ \_/ isort your imports, so you don't have to. VERSION 5.5.2 yajo@toolbox:~/p/myproject-odoo|BOT-autoupdate⚡* ➤ pipx run isort odoo/custom/src/private/base_rest_api/services/exception_services.py --show-config { "_known_patterns": null, "_section_comments": null, "py_version": "py3", "force_to_top": [], "skip": [ ".pants.d", ".nox", ".git", ".tox", "buck-out", "build", ".eggs", ".bzr", "dist", ".direnv", "_build", ".svn", ".venv", ".mypy_cache", ".hg", "venv", "node_modules" ], "skip_glob": [], "skip_gitignore": false, "line_length": 79, "wrap_length": 0, "line_ending": "", "sections": [ "FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER" ], "no_sections": false, "known_future_library": [ "__future__" ], "known_third_party": [], "known_first_party": [], "known_local_folder": [], "known_standard_library": [ "ensurepip", "site", "filecmp", "colorsys", "mimetypes", "abc", "codeop", "bisect", "xmlrpc", "zipapp", "datetime", "subprocess", "os", "faulthandler", "select", "platform", "_dummy_thread", "errno", "cmath", "ipaddress", "binhex", "lzma", "typing", "cgi", "csv", "chunk", "numbers", "glob", "uuid", "dummy_threading", "struct", "unittest", "ntpath", "test", "telnetlib", "timeit", "netrc", "compileall", "imp", "grp", "smtpd", "ssl", "zipfile", "uu", "calendar", "sched", "mmap", "codecs", "ast", "random", "json", "operator", "atexit", "textwrap", "urllib", "zipimport", "bz2", "weakref", "getopt", "types", "zlib", "rlcompleter", "shelve", "trace", "tracemalloc", "signal", "quopri", "token", "shlex", "ossaudiodev", "pprint", "dataclasses", "configparser", "pathlib", "nis", "sre_compile", "readline", "stringprep", "tabnanny", "termios", "imghdr", "pickle", "posix", "plistlib", "socketserver", "socket", "asynchat", "code", "encodings", "reprlib", "sndhdr", "pickletools", "itertools", "html", "xml", "cgitb", "sre_constants", "copy", "sunau", "syslog", "audioop", "queue", "multiprocessing", "tempfile", "gzip", "importlib", "functools", "curses", "hmac", "decimal", "asyncore", "io", "winreg", "parser", "pipes", "locale", "asyncio", "sqlite3", "sys", "symtable", "string", "_thread", "marshal", "mailcap", "posixpath", "getpass", "re", "collections", "pyclbr", "pdb", "keyword", "difflib", "threading", "pydoc", "linecache", "warnings", "secrets", "inspect", "logging", "gc", "binascii", "hashlib", "aifc", "traceback", "profile", "array", "crypt", "fcntl", "tarfile", "py_compile", "statistics", "email", "http", "math", "wave", "turtle", "optparse", "dbm", "tkinter", "xdrlib", "msvcrt", "enum", "distutils", "cProfile", "fileinput", "pwd", "tty", "fnmatch", "spwd", "poplib", "wsgiref", "argparse", "ftplib", "stat", "turtledemo", "concurrent", "pkgutil", "webbrowser", "msilib", "tokenize", "runpy", "sre_parse", "ctypes", "fractions", "shutil", "pty", "venv", "bdb", "formatter", "gettext", "contextvars", "sysconfig", "unicodedata", "doctest", "copyreg", "fpectl", "modulefinder", "smtplib", "dis", "selectors", "nntplib", "heapq", "symbol", "winsound", "base64", "cmd", "macpath", "mailbox", "contextlib", "builtins", "lib2to3", "sre", "pstats", "imaplib", "resource", "time" ], "extra_standard_library": [], "known_other": {}, "multi_line_output": "GRID", "forced_separate": [], "indent": " ", "comment_prefix": " #", "length_sort": false, "length_sort_straight": false, "length_sort_sections": [], "add_imports": [], "remove_imports": [], "append_only": false, "reverse_relative": false, "force_single_line": false, "single_line_exclusions": [], "default_section": "THIRDPARTY", "import_headings": {}, "balanced_wrapping": false, "use_parentheses": false, "order_by_type": true, "atomic": false, "lines_after_imports": -1, "lines_between_sections": 1, "lines_between_types": 0, "combine_as_imports": false, "combine_star": false, "include_trailing_comma": false, "from_first": false, "verbose": false, "quiet": false, "force_adds": false, "force_alphabetical_sort_within_sections": false, "force_alphabetical_sort": false, "force_grid_wrap": 0, "force_sort_within_sections": false, "lexicographical": false, "ignore_whitespace": false, "no_lines_before": [], "no_inline_sort": false, "ignore_comments": false, "case_sensitive": false, "sources": [ { "py_version": "py3", "force_to_top": [], "skip": [ ".pants.d", ".nox", ".git", ".tox", "buck-out", "build", ".eggs", ".bzr", "dist", ".direnv", "_build", ".svn", ".venv", ".mypy_cache", ".hg", "venv", "node_modules" ], "skip_glob": [], "skip_gitignore": false, "line_length": 79, "wrap_length": 0, "line_ending": "", "sections": [ "FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER" ], "no_sections": false, "known_future_library": [ "__future__" ], "known_third_party": [], "known_first_party": [], "known_local_folder": [], "known_standard_library": [ "ensurepip", "site", "filecmp", "colorsys", "mimetypes", "abc", "codeop", "bisect", "xmlrpc", "zipapp", "datetime", "subprocess", "os", "faulthandler", "select", "platform", "_dummy_thread", "errno", "cmath", "ipaddress", "binhex", "lzma", "typing", "cgi", "csv", "chunk", "numbers", "glob", "uuid", "dummy_threading", "struct", "unittest", "ntpath", "test", "telnetlib", "timeit", "netrc", "compileall", "imp", "grp", "smtpd", "ssl", "zipfile", "uu", "calendar", "sched", "mmap", "codecs", "ast", "random", "json", "operator", "atexit", "textwrap", "urllib", "zipimport", "bz2", "weakref", "getopt", "types", "zlib", "rlcompleter", "shelve", "trace", "tracemalloc", "signal", "quopri", "token", "shlex", "ossaudiodev", "pprint", "dataclasses", "configparser", "pathlib", "nis", "sre_compile", "readline", "stringprep", "tabnanny", "termios", "imghdr", "pickle", "posix", "plistlib", "socketserver", "socket", "asynchat", "code", "encodings", "reprlib", "sndhdr", "pickletools", "itertools", "html", "xml", "cgitb", "sre_constants", "copy", "sunau", "syslog", "audioop", "queue", "multiprocessing", "tempfile", "gzip", "importlib", "functools", "curses", "hmac", "decimal", "asyncore", "io", "winreg", "parser", "pipes", "locale", "asyncio", "sqlite3", "sys", "symtable", "string", "_thread", "marshal", "mailcap", "posixpath", "getpass", "re", "collections", "pyclbr", "pdb", "keyword", "difflib", "threading", "pydoc", "linecache", "warnings", "secrets", "inspect", "logging", "gc", "binascii", "hashlib", "aifc", "traceback", "profile", "array", "crypt", "fcntl", "tarfile", "py_compile", "statistics", "email", "http", "math", "wave", "turtle", "optparse", "dbm", "tkinter", "xdrlib", "msvcrt", "enum", "distutils", "cProfile", "fileinput", "pwd", "tty", "fnmatch", "spwd", "poplib", "wsgiref", "argparse", "ftplib", "stat", "turtledemo", "concurrent", "pkgutil", "webbrowser", "msilib", "tokenize", "runpy", "sre_parse", "ctypes", "fractions", "shutil", "pty", "venv", "bdb", "formatter", "gettext", "contextvars", "sysconfig", "unicodedata", "doctest", "copyreg", "fpectl", "modulefinder", "smtplib", "dis", "selectors", "nntplib", "heapq", "symbol", "winsound", "base64", "cmd", "macpath", "mailbox", "contextlib", "builtins", "lib2to3", "sre", "pstats", "imaplib", "resource", "time" ], "extra_standard_library": [], "known_other": {}, "multi_line_output": "GRID", "forced_separate": [], "indent": " ", "comment_prefix": " #", "length_sort": false, "length_sort_straight": false, "length_sort_sections": [], "add_imports": [], "remove_imports": [], "append_only": false, "reverse_relative": false, "force_single_line": false, "single_line_exclusions": [], "default_section": "THIRDPARTY", "import_headings": {}, "balanced_wrapping": false, "use_parentheses": false, "order_by_type": true, "atomic": false, "lines_after_imports": -1, "lines_between_sections": 1, "lines_between_types": 0, "combine_as_imports": false, "combine_star": false, "include_trailing_comma": false, "from_first": false, "verbose": false, "quiet": false, "force_adds": false, "force_alphabetical_sort_within_sections": false, "force_alphabetical_sort": false, "force_grid_wrap": 0, "force_sort_within_sections": false, "lexicographical": false, "ignore_whitespace": false, "no_lines_before": [], "no_inline_sort": false, "ignore_comments": false, "case_sensitive": false, "sources": [], "virtual_env": "", "conda_env": "", "ensure_newline_before_comments": false, "directory": "", "profile": "", "honor_noqa": false, "src_paths": [], "old_finders": false, "remove_redundant_aliases": false, "float_to_top": false, "filter_files": false, "formatter": "", "formatting_function": null, "color_output": false, "treat_comments_as_code": [], "treat_all_comments_as_code": false, "supported_extensions": [ "py", "pyx", "pyi" ], "blocked_extensions": [ "pex" ], "constants": [], "classes": [], "variables": [], "dedup_headings": false, "source": "defaults" }, { "source": "/var/home/yajo/prodevel/myproject-odoo/odoo/custom/src/private/.editorconfig", "indent": " " } ], "virtual_env": "", "conda_env": "", "ensure_newline_before_comments": false, "directory": "/var/home/yajo/prodevel/myproject-odoo/odoo/custom/src/private", "profile": "", "honor_noqa": false, "src_paths": [ "/var/home/yajo/prodevel/myproject-odoo/odoo/custom/src/private", "/var/home/yajo/prodevel/myproject-odoo/odoo/custom/src/private/src" ], "old_finders": false, "remove_redundant_aliases": false, "float_to_top": false, "filter_files": false, "formatter": "", "formatting_function": null, "color_output": false, "treat_comments_as_code": [], "treat_all_comments_as_code": false, "supported_extensions": [ "py", "pyx", "pyi" ], "blocked_extensions": [ "pex" ], "constants": [], "classes": [], "variables": [], "dedup_headings": false } yajo@toolbox:~/p/myproject-odoo|BOT-autoupdate⚡* ➤ pipx run isort odoo/custom/src/private/base_rest_api/services/exception_services.py --show-config --settings-path . { "_known_patterns": null, "_section_comments": null, "py_version": "py3", "force_to_top": [], "skip": [ ".bzr", ".nox", ".hg", "venv", "dist", ".direnv", ".git", ".svn", ".pants.d", "_build", "node_modules", ".mypy_cache", ".tox", "buck-out", ".eggs", "build", ".venv" ], "skip_glob": [], "skip_gitignore": false, "line_length": 88, "wrap_length": 0, "line_ending": "", "sections": [ "FUTURE", "STDLIB", "THIRDPARTY", "ODOO", "ODOO_ADDONS", "FIRSTPARTY", "LOCALFOLDER" ], "no_sections": false, "known_future_library": [ "__future__" ], "known_third_party": [], "known_first_party": [], "known_local_folder": [], "known_standard_library": [ "turtle", "asyncio", "builtins", "symbol", "dataclasses", "collections", "msvcrt", "msilib", "site", "asyncore", "statistics", "textwrap", "sys", "posixpath", "contextvars", "asynchat", "os", "imp", "platform", "functools", "gzip", "netrc", "zipapp", "bdb", "sndhdr", "ipaddress", "smtpd", "test", "tarfile", "sysconfig", "secrets", "curses", "array", "traceback", "zipimport", "grp", "resource", "code", "struct", "cProfile", "token", "multiprocessing", "cmath", "glob", "pwd", "shutil", "pickletools", "termios", "email", "difflib", "binhex", "math", "string", "cmd", "gettext", "uuid", "unittest", "distutils", "telnetlib", "unicodedata", "tabnanny", "select", "colorsys", "types", "faulthandler", "parser", "cgitb", "plistlib", "getpass", "calendar", "sched", "queue", "signal", "xdrlib", "urllib", "json", "pprint", "lib2to3", "turtledemo", "chunk", "copyreg", "xml", "nis", "_dummy_thread", "time", "shelve", "hmac", "encodings", "tracemalloc", "pyclbr", "sre_parse", "timeit", "formatter", "syslog", "dbm", "codecs", "tempfile", "ctypes", "posix", "ssl", "pathlib", "pkgutil", "fnmatch", "warnings", "operator", "smtplib", "sre_compile", "webbrowser", "socketserver", "bz2", "ftplib", "selectors", "zipfile", "trace", "linecache", "mmap", "stat", "dis", "sunau", "wave", "crypt", "locale", "codeop", "pydoc", "copy", "sqlite3", "re", "runpy", "dummy_threading", "stringprep", "winreg", "random", "weakref", "audioop", "http", "fpectl", "tty", "fcntl", "ensurepip", "getopt", "uu", "sre", "lzma", "doctest", "cgi", "ast", "rlcompleter", "argparse", "enum", "base64", "decimal", "fractions", "atexit", "poplib", "modulefinder", "symtable", "wsgiref", "binascii", "py_compile", "pipes", "keyword", "pty", "concurrent", "nntplib", "heapq", "sre_constants", "winsound", "imaplib", "imghdr", "fileinput", "importlib", "profile", "optparse", "ntpath", "spwd", "pickle", "venv", "_thread", "tkinter", "aifc", "tokenize", "typing", "hashlib", "readline", "subprocess", "marshal", "abc", "zlib", "ossaudiodev", "xmlrpc", "bisect", "itertools", "contextlib", "datetime", "mailbox", "html", "numbers", "io", "pstats", "socket", "compileall", "mimetypes", "shlex", "errno", "gc", "pdb", "filecmp", "reprlib", "inspect", "mailcap", "macpath", "threading", "csv", "configparser", "logging", "quopri" ], "extra_standard_library": [], "known_other": { "odoo": [ "odoo" ], "odoo_addons": [ "odoo.addons" ] }, "multi_line_output": "VERTICAL_HANGING_INDENT", "forced_separate": [], "indent": " ", "comment_prefix": " #", "length_sort": false, "length_sort_straight": false, "length_sort_sections": [], "add_imports": [], "remove_imports": [], "append_only": false, "reverse_relative": false, "force_single_line": false, "single_line_exclusions": [], "default_section": "THIRDPARTY", "import_headings": {}, "balanced_wrapping": false, "use_parentheses": true, "order_by_type": true, "atomic": false, "lines_after_imports": -1, "lines_between_sections": 1, "lines_between_types": 0, "combine_as_imports": true, "combine_star": false, "include_trailing_comma": true, "from_first": false, "verbose": false, "quiet": false, "force_adds": false, "force_alphabetical_sort_within_sections": false, "force_alphabetical_sort": false, "force_grid_wrap": 0, "force_sort_within_sections": false, "lexicographical": false, "ignore_whitespace": false, "no_lines_before": [], "no_inline_sort": false, "ignore_comments": false, "case_sensitive": false, "sources": [ { "py_version": "py3", "force_to_top": [], "skip": [ ".bzr", ".nox", ".hg", "venv", "dist", ".direnv", ".git", ".svn", ".pants.d", "_build", "node_modules", ".mypy_cache", ".tox", "buck-out", ".eggs", "build", ".venv" ], "skip_glob": [], "skip_gitignore": false, "line_length": 79, "wrap_length": 0, "line_ending": "", "sections": [ "FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER" ], "no_sections": false, "known_future_library": [ "__future__" ], "known_third_party": [], "known_first_party": [], "known_local_folder": [], "known_standard_library": [ "turtle", "asyncio", "builtins", "symbol", "dataclasses", "collections", "msvcrt", "msilib", "site", "asyncore", "statistics", "textwrap", "sys", "posixpath", "contextvars", "asynchat", "os", "imp", "platform", "functools", "gzip", "netrc", "zipapp", "bdb", "sndhdr", "ipaddress", "smtpd", "test", "tarfile", "sysconfig", "secrets", "curses", "array", "traceback", "zipimport", "grp", "resource", "code", "struct", "cProfile", "token", "multiprocessing", "cmath", "glob", "pwd", "shutil", "pickletools", "termios", "email", "difflib", "binhex", "math", "string", "cmd", "gettext", "uuid", "unittest", "distutils", "telnetlib", "unicodedata", "tabnanny", "select", "colorsys", "types", "faulthandler", "parser", "cgitb", "plistlib", "getpass", "calendar", "sched", "queue", "signal", "xdrlib", "urllib", "json", "pprint", "lib2to3", "turtledemo", "chunk", "copyreg", "xml", "nis", "_dummy_thread", "time", "shelve", "hmac", "encodings", "tracemalloc", "pyclbr", "sre_parse", "timeit", "formatter", "syslog", "dbm", "codecs", "tempfile", "ctypes", "posix", "ssl", "pathlib", "pkgutil", "fnmatch", "warnings", "operator", "smtplib", "sre_compile", "webbrowser", "socketserver", "bz2", "ftplib", "selectors", "zipfile", "trace", "linecache", "mmap", "stat", "dis", "sunau", "wave", "crypt", "locale", "codeop", "pydoc", "copy", "sqlite3", "re", "runpy", "dummy_threading", "stringprep", "winreg", "random", "weakref", "audioop", "http", "fpectl", "tty", "fcntl", "ensurepip", "getopt", "uu", "sre", "lzma", "doctest", "cgi", "ast", "rlcompleter", "argparse", "enum", "base64", "decimal", "fractions", "atexit", "poplib", "modulefinder", "symtable", "wsgiref", "binascii", "py_compile", "pipes", "keyword", "pty", "concurrent", "nntplib", "heapq", "sre_constants", "winsound", "imaplib", "imghdr", "fileinput", "importlib", "profile", "optparse", "ntpath", "spwd", "pickle", "venv", "_thread", "tkinter", "aifc", "tokenize", "typing", "hashlib", "readline", "subprocess", "marshal", "abc", "zlib", "ossaudiodev", "xmlrpc", "bisect", "itertools", "contextlib", "datetime", "mailbox", "html", "numbers", "io", "pstats", "socket", "compileall", "mimetypes", "shlex", "errno", "gc", "pdb", "filecmp", "reprlib", "inspect", "mailcap", "macpath", "threading", "csv", "configparser", "logging", "quopri" ], "extra_standard_library": [], "known_other": {}, "multi_line_output": "GRID", "forced_separate": [], "indent": " ", "comment_prefix": " #", "length_sort": false, "length_sort_straight": false, "length_sort_sections": [], "add_imports": [], "remove_imports": [], "append_only": false, "reverse_relative": false, "force_single_line": false, "single_line_exclusions": [], "default_section": "THIRDPARTY", "import_headings": {}, "balanced_wrapping": false, "use_parentheses": false, "order_by_type": true, "atomic": false, "lines_after_imports": -1, "lines_between_sections": 1, "lines_between_types": 0, "combine_as_imports": false, "combine_star": false, "include_trailing_comma": false, "from_first": false, "verbose": false, "quiet": false, "force_adds": false, "force_alphabetical_sort_within_sections": false, "force_alphabetical_sort": false, "force_grid_wrap": 0, "force_sort_within_sections": false, "lexicographical": false, "ignore_whitespace": false, "no_lines_before": [], "no_inline_sort": false, "ignore_comments": false, "case_sensitive": false, "sources": [], "virtual_env": "", "conda_env": "", "ensure_newline_before_comments": false, "directory": "", "profile": "", "honor_noqa": false, "src_paths": [], "old_finders": false, "remove_redundant_aliases": false, "float_to_top": false, "filter_files": false, "formatter": "", "formatting_function": null, "color_output": false, "treat_comments_as_code": [], "treat_all_comments_as_code": false, "supported_extensions": [ "py", "pyi", "pyx" ], "blocked_extensions": [ "pex" ], "constants": [], "classes": [], "variables": [], "dedup_headings": false, "source": "defaults" }, { "multi_line_output": "VERTICAL_HANGING_INDENT", "include_trailing_comma": true, "force_grid_wrap": 0, "combine_as_imports": true, "use_parentheses": true, "line_length": 88, "known_odoo": [ "odoo" ], "known_odoo_addons": [ "odoo.addons" ], "sections": [ "FUTURE", "STDLIB", "THIRDPARTY", "ODOO", "ODOO_ADDONS", "FIRSTPARTY", "LOCALFOLDER" ], "default_section": "THIRDPARTY", "source": "/var/home/yajo/prodevel/myproject-odoo/.isort.cfg" } ], "virtual_env": "", "conda_env": "", "ensure_newline_before_comments": false, "directory": "/var/home/yajo/prodevel/myproject-odoo", "profile": "", "honor_noqa": false, "src_paths": [ "/var/home/yajo/prodevel/myproject-odoo", "/var/home/yajo/prodevel/myproject-odoo/src" ], "old_finders": false, "remove_redundant_aliases": false, "float_to_top": false, "filter_files": false, "formatter": "", "formatting_function": null, "color_output": false, "treat_comments_as_code": [], "treat_all_comments_as_code": false, "supported_extensions": [ "py", "pyi", "pyx" ], "blocked_extensions": [ "pex" ], "constants": [], "classes": [], "variables": [], "dedup_headings": false } ```
anirudnits commented 4 years ago

@Yajo isort seeks the .isort.cfg seeks from the root directory of the file and then the directory from where it was invoked and if both the file directory as the calling directory have a .isort.cfg file then the cfg file in the file directory takes precedence.

yajo commented 4 years ago

Then it seems to have some kind of bug. Does it take into account a directory specifically called src?

anirudnits commented 4 years ago

if "settings_path" not in arguments: arguments["settings_path"] = ( os.path.abspath(file_names[0] if file_names else ".") or os.getcwd() )

that's the portion of code that handles that

anirudnits commented 4 years ago

@Yajo I think its cool at least how I see it. But yeah I think better documentation would be good. @timothycrosley any thoughts?

yajo commented 4 years ago

Ah of course there's the problem. It should default to . always IMHO.

yajo commented 4 years ago

Or at least that's a regression from v4, so if this is how it is now, it should get docummented in the migration guide, because previous pre-commit hooks wouldn't work as-is.

timothycrosley commented 4 years ago

@Yajo,

I'm sorry this behaviour led to confusion. It is not a regression, but an intentional change in behaviour. I tried my best to outline this behaviour in the top of the configuration file documentation: https://pycqa.github.io/isort/docs/configuration/config_files/:

You can manually specify the settings file or path by setting --settings-path from the command-line. Otherwise, isort will traverse up to 25 parent directories until it finds a suitable config file. As soon as it finds a file, it stops looking. The config file search is done relative to the current directory if isort . or a file stream is passed in, or relative to the first path passed in if multiple paths are passed in. isort never merges config files together due to the confusion it can cause.

I also called out how this behaviour had changed in v5 and linked to that documentation from the migration guide: https://pycqa.github.io/isort/docs/upgrade_guides/5.0.0/#migrating-config-options.

Any advice on how I can better call it out? Perhaps a tip by the pre-commit section?

Thanks!

~Timothy

yajo commented 4 years ago

AFAICS I definitely did not find that but it is properly documented.

Any advice on how I can better call it out? Perhaps a tip by the pre-commit section?

Yes, and make it more relevant in the upgrading guide, like adding a header just about that.