topmark.resolution.files¶
topmark / resolution / files
Resolve the concrete filesystem inputs that TopMark should process.
This module expands configured or positional paths, applies include/exclude pattern filters, optionally constrains the candidate set by configured file type identifiers, and returns a deterministic list of files to process.
Conceptually, this module answers a different question from
topmark.resolution.filetypes:
topmark.resolution.filesdecides which files should be processed;topmark.resolution.filetypesdecides what each file is.
Positional globs are expanded relative to the current working directory (CWD).
Globs declared in configuration files are expanded relative to the directory of
each declaring config file. Paths loaded from files_from sources are resolved
against their declaring source base directory.
The module also provides discovery-level probe helpers for topmark probe.
Those helpers explain why explicitly requested paths did not reach file-type
probing, without enumerating every recursively discovered file excluded during
normal traversal.
FileListResolution
dataclass
¶
Resolved file-list result plus discovery diagnostics.
Attributes:
| Name | Type | Description |
|---|---|---|
selected |
tuple[Path, ...]
|
Concrete files selected for processing. |
missing_literals |
tuple[Path, ...]
|
Explicit literal input paths that do not exist. |
unmatched_patterns |
tuple[str, ...]
|
Glob patterns that matched no files. |
load_patterns_from_file ¶
Load non-empty, non-comment patterns from a text file.
The pattern semantics mirror .gitignore: each pattern is later evaluated
relative to the pattern file's own base directory (source.base).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PatternSource
|
Reference to the pattern file and its base. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of patterns as strings. |
Source code in src/topmark/resolution/files.py
probe_explicit_file_selection ¶
Explain explicit inputs that were not selected for file-type probing.
This helper is intentionally narrow: it only reports paths explicitly named
through positional inputs or files_from. It does not enumerate every file
excluded during recursive directory traversal, because that could produce
unexpectedly large diagnostic output for topmark probe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
Effective layered configuration used for file discovery. |
required |
selected_files
|
Sequence[Path]
|
Files selected by |
required |
Returns:
| Type | Description |
|---|---|
FileSelectionProbeResult
|
Discovery-level probe results for explicit inputs that did not reach |
...
|
file-type probing. |
Source code in src/topmark/resolution/files.py
resolve_file_list_with_diagnostics ¶
Return concrete input files plus discovery diagnostics.
The resolver implements these semantics
- Candidate set: Expand positional paths (files, directories recursively, and globs).
If no positional paths are provided, extend with any literal paths read from
--files-frombefore filtering. If the candidate set is still empty and include globs are configured, expand those include globs from both the current working directory (CLI perspective) and each discovered/explicit config file's directory (config perspective) to seed candidates. - File-only: Only files (not directories) are kept for filtering.
- Include intersection: If any include patterns
(from include pattern groups or
include_fromfiles) are given, filter the candidate set to only those files matching any include pattern (intersection filter). - Exclude subtraction: If any exclude patterns
(from exclude pattern groups or
exclude_fromfiles) are given, remove any files matching the exclusion patterns from the set. - File type filter: If
include_file_typesorexclude_file_typesare specified, further restrict to files matching those types. - Returns a sorted list of Path objects for deterministic output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
Effective layered configuration. |
required |
Returns:
| Type | Description |
|---|---|
FileListResolution
|
|
FileListResolution
|
containing selected files and discovery diagnostics. |
Source code in src/topmark/resolution/files.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 | |