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

Fix misdetection of project root when --stdin-filename filepath is outside the current working directory #3208

Closed

Conversation

n-borges
Copy link
Contributor

@n-borges n-borges commented Aug 4, 2022

Description

Fixes behaviour that prevented formatting for files outside the current working directory (#3207).

# before the fixcat ../script.py | python -m black --stdin-filename '../script.py' -
No Python files are present to be formatted. Nothing to do 😴

# after the fix cat ../test.py | python -m black --stdin-filename '../test.py' -   
print("hello world")
All done! ✨ 🍰 ✨
1 file left unchanged.

Let me know what you think! Not sure about how elegant the solution is, but I would be happy to refactor it based on your suggestions.

Checklist - did you ...

  • Add a CHANGELOG entry if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

@github-actions
Copy link

github-actions bot commented Aug 4, 2022

diff-shades reports zero changes comparing this PR (3daf8a7) to main (507234c).


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

@ichard26 ichard26 self-requested a review August 5, 2022 17:01
@felix-hilden
Copy link
Collaborator

Oh, this seems to overlap with #3216 most unfortunately. Although it is quite a simple solution. Not sure which would be better, but I'd like to see a more concrete test related to the original issue if you're up for the race :P

@ichard26
Copy link
Collaborator

Hey, so #3216 was filed as an alternative fix for the same issue. I chose it over yours as it's probably more maintainable in the longterm by maintaining the invariant the project root contains the files to be formatted. Thanks for submitting a PR anyway, perhaps they got interested in fixing this issue too by your PR :)

Have a great day/night!

@ichard26 ichard26 closed this Aug 26, 2022
@ichard26 ichard26 removed their request for review August 26, 2022 21:15
@n-borges
Copy link
Contributor Author

Great, happy this issue has been solved!

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.

3 participants