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

HEROgold / funcsort / 30719014411
96%

Build:
DEFAULT BRANCH: main
Ran 01 Aug 2026 09:23PM UTC
Jobs 1
Files 21
Run time 1min
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

01 Aug 2026 09:22PM UTC coverage: 96.497% (+3.8%) from 92.732%
30719014411

push

github

web-flow
fix: never reorder a definition below code that reads it at import time (#2)

* fix: never reorder a definition below code that reads it at import time

funcsort ordered class and module bodies purely by group, with no model of
load-time name dependencies. Anything a statement reads *while it executes* --
a decorator expression, a parameter default, an assignment RHS -- must already
be bound, so sorting could hoist a definition above its referent and leave the
file raising NameError on import.

It hit this repo: `@given(_class_source())` on a public `test_*` function was
sorted above the protected `_class_source` it calls.

Two new modules, mirroring the existing pure/adapter split:

- references.py (libcst adapter) separates eager references, which constrain
  ordering, from lazy ones, which never do. Function and lambda bodies are lazy,
  so mutual recursion still sorts freely; class bodies are eager; annotations
  are eager unless the module uses `from __future__ import annotations`.
  Over-collection is the safe direction and is preferred throughout.

- ordering.py (pure) fits the preferred order to those constraints. Anchors hold
  fixed indices and candidates fill the remaining slots, subject to precedence
  edges, release times and deadlines. A valid desired order is emitted verbatim,
  so dependency-free code is byte-identical to before; otherwise a deterministic
  earliest-deadline-first greedy repairs it. Since the input file already runs,
  its own order is always feasible and is the fallback when no safe order is
  found -- funcsort warns rather than emitting code that cannot import.

sort_block now iterates bucketing and solving to a fixed point. The
minimise-movement heuristic is position-dependent, so without this a repaired
order could oscillate and rewrite the same file on alternate pre-commit runs.

Exposed as `respect_dependencies` (default true) plus --no-respect-dependencies,
wired like the existing sort_module flag.

Only members... (continued)

720 of 728 new or added lines in 13 files covered. (98.9%)

26 existing lines in 5 files now uncovered.

1873 of 1941 relevant lines covered (96.5%)

0.96 hits per line

Uncovered Changes

Lines Coverage ∆ File
5
95.31
0.23% src/funcsort/sorter.py
3
94.34
tests/importability.py

Coverage Regressions

Lines Coverage ∆ File
12
95.31
0.23% src/funcsort/sorter.py
8
82.83
33.34% src/funcsort/main.py
3
95.83
0.0% src/funcsort/groups.py
2
97.47
0.25% src/funcsort/config.py
1
99.19
0.24% tests/test_properties.py
Jobs
ID Job ID Ran Files Coverage
1 30719014411.1 01 Aug 2026 09:23PM UTC 21
96.5
GitHub Action Run
Source Files on build 30719014411
  • Tree
  • List 21
  • Changed 9
  • Source Changed 0
  • Coverage Changed 9
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 759aac15 on github
  • Prev Build on main (#30141282539)
  • Next Build on main (#30720283894)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc