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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve symlinks when checking which files to format #4215

Closed
wants to merge 1 commit into from

Conversation

nfvs
Copy link

@nfvs nfvs commented Feb 7, 2024

Description

Currently find_project_root() resolves symlinks, but get_sources() doesn't, so trying to format a file that contains symlinks will fail:

$ python -m black --check /home/nfvs/code/black/src/black/files.py
No Python files are present to be formatted. Nothing to do 馃槾

This commit changes methods used in get_sources() to, like find_project_root(), use Path.resolve() instead of Path.absolute(), which will follow symlinks.

Also fixes:

Checklist - did you ...

  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

Currently `find_project_root()` resolves symlinks, but `get_sources()`
doesn't, so trying to format a file that contains symlinks will fail:
```
$ python -m black --check /home/nfvs/code/black/src/black/files.py
No Python files are present to be formatted. Nothing to do 馃槾
```

This commit changes methods used in `get_sources()` to, like
`find_project_root()`, use `Path.resolve()` instead of
`Path.absolute()`, which will follow symlinks.
Copy link

github-actions bot commented Feb 7, 2024

diff-shades reports zero changes comparing this PR (689ecad) to main (dab37a6).


What is this? | Workflow run | diff-shades documentation

@nfvs
Copy link
Author

nfvs commented Feb 9, 2024

Test failures may be due to another bug: #3552

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, but the tests that are failing test important behaviour. Do you have a small repro of the case where you want current behaviour to be different?

@hauntsaninja
Copy link
Collaborator

If you get a moment, would you mind testing #4222 and see if it works for your use case?

@nfvs
Copy link
Author

nfvs commented Feb 11, 2024

If you get a moment, would you mind testing #4222 and see if it works for your use case?

@hauntsaninja It does fix it, I'll close this PR. Thanks!

@nfvs nfvs closed this Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants