Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive settings_path from --filename #1992

Merged
merged 2 commits into from
Feb 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion isort/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,9 @@ def main(argv: Optional[Sequence[str]] = None, stdin: Optional[TextIOWrapper] =
return
if "settings_path" not in arguments:
arguments["settings_path"] = (
os.path.abspath(file_names[0] if file_names else ".") or os.getcwd()
arguments.get("filename", None) or os.getcwd()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
arguments.get("filename", None) or os.getcwd()
os.path.abspath(arguments.get("filename", None) or os.getcwd())

Should --filename argument be wrapped with abspath as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's confusing because then it depends on the working dir again. The working dir is not as easy to get right for editors; it might be the topmost open folder, or the first folder with .git in it. And then we need to construct a relative filename of course to set it as the argument.

if file_names == ["-"] else
os.path.abspath(file_names[0] if file_names else ".")
)
if not os.path.isdir(arguments["settings_path"]):
arguments["settings_path"] = os.path.dirname(arguments["settings_path"])
Expand Down