Skip to content

Black should never try to format symlinks #3880

@JelleZijlstra

Description

@JelleZijlstra

After upgrading to 23.9.1, due to #3846 I ran into the following situation:

  • a/file.py is a symlink to b/file.py
  • b/file.py is not formatted because it's in exclude

Previously, Black ignored the file. Now it wants to format it.

I would expect Black to not format these files. The actual files are excluded, the symlinks aren't themselves Python files. I think this can be implemented with a simple rule: never follow symlinks. If the file is in a place that Black should format, we'll find it through its resolved path. If it's not, we shouldn't format it.

cc @hauntsaninja

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions