• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

psf / black / 7868792274
96%
master: 96%

Build:
Build:
LAST BUILD BRANCH: pre-commit-ci-update-config
DEFAULT BRANCH: master
Ran 12 Feb 2024 08:06AM UTC
Jobs 5
Files 40
Run time 5s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Feb 2024 08:04AM UTC coverage: 96.415% (+0.03%) from 96.387%
7868792274

push

github

web-flow
Fix ignoring input files for symlink reasons (#4222)

This relates to #4015, #4161 and the behaviour of os.getcwd()

Black is a big user of pathlib and as such loves doing `.resolve()`,
since for a long time it was the only good way of getting an absolute
path in pathlib. However, this has two problems:

The first minor problem is performance, e.g. in #3751 I (safely) got rid
of a bunch of `.resolve()` which made Black 40% faster on cached runs.

The second more important problem is that always resolving symlinks
results in unintuitive exclusion behaviour. For instance, a gitignored
symlink should never alter formatting of your actual code. This kind of
thing was reported by users a few times.

In #3846, I improved the exclusion rule logic for symlinks in
`gen_python_files` and everything was good.

But `gen_python_files` isn't enough, there's also `get_sources`, which
handles user specified paths directly (instead of files Black
discovers). So in #4015, I made a very similar change to #3846 for
`get_sources`, and this is where some problems began.

The core issue was the line:
```
root_relative_path = path.absolute().relative_to(root).as_posix()
```
The first issue is that despite root being computed from user inputs, we
call `.resolve()` while computing it (likely unecessarily). Which means
that `path` may not actually be relative to `root`. So I started off
this PR trying to fix that, when I ran into the second issue. Which is
that `os.getcwd()` (as called by `os.path.abspath` or `Path.absolute` or
`Path.cwd`) also often resolves symlinks!
```
>>> import os
>>> os.environ.get("PWD")
'/Users/shantanu/dev/black/symlink/bug'
>>> os.getcwd()
'/Users/shantanu/dev/black/actual/bug'
```
This also meant that the breakage often would not show up when input
relative paths.

This doesn't affect `gen_python_files` / #3846 because things are always
absolute and known to be relative to `root`.

Anyway, it looks like #... (continued)

3083 of 3298 branches covered (0.0%)

7289 of 7560 relevant lines covered (96.42%)

4.81 hits per line

Jobs
ID Job ID Ran Files Coverage
1 py3.12-ubuntu-latest - 7868792274.1 12 Feb 2024 08:11AM UTC 40
96.31
2 py3.11-ubuntu-latest - 7868792274.2 12 Feb 2024 08:11AM UTC 40
96.31
3 py3.8-ubuntu-latest - 7868792274.3 12 Feb 2024 08:11AM UTC 40
96.22
4 py3.9-ubuntu-latest - 7868792274.4 12 Feb 2024 08:11AM UTC 40
96.23
5 py3.10-ubuntu-latest - 7868792274.5 12 Feb 2024 08:11AM UTC 40
96.3
Source Files on build 7868792274
  • Tree
  • List 40
  • Changed 3
  • Source Changed 0
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 23dfc5b2 on github
  • Prev Build on main (#7860585323)
  • Next Build on main (#7873112645)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc