Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Tools/build/compute-changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
from dataclasses import dataclass
from pathlib import Path

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Set

GITHUB_DEFAULT_BRANCH = os.environ["GITHUB_DEFAULT_BRANCH"]
GITHUB_CODEOWNERS_PATH = Path(".github/CODEOWNERS")
GITHUB_WORKFLOWS_PATH = Path(".github/workflows")
Expand Down Expand Up @@ -83,7 +79,7 @@ def git_branches() -> tuple[str, str]:

def get_changed_files(
ref_a: str = GITHUB_DEFAULT_BRANCH, ref_b: str = "HEAD"
) -> Set[Path]:
) -> frozenset[Path]:
"""List the files changed between two Git refs, filtered by change type."""
args = ("git", "diff", "--name-only", f"{ref_a}...{ref_b}", "--")
print(*args)
Expand All @@ -94,7 +90,7 @@ def get_changed_files(
return frozenset(map(Path, filter(None, map(str.strip, changed_files))))


def process_changed_files(changed_files: Set[Path]) -> Outputs:
def process_changed_files(changed_files: frozenset[Path]) -> Outputs:
run_tests = False
run_ci_fuzz = False
run_docs = False
Expand Down
2 changes: 1 addition & 1 deletion Tools/build/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
files = Tools/build/generate_sbom.py
files = Tools/build/generate_sbom.py, Tools/build/compute-changes.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a multi-line list? Ideally we could use a TOML file, does MyPy support mypy.toml or .mypy.toml?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It supports pyproject.toml, but it can affect stuff. + Our CI expects all folders to have mypy.ini. Current version of mypy does not support multiline strings here. But, I will fix that upstream. So, we can expect this in 1.16.0 somewhere.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work like this?

Suggested change
files = Tools/build/generate_sbom.py, Tools/build/compute-changes.py
files =
Tools/build/compute-changes.py,
Tools/build/generate_sbom.py

(Unfortunately can't add a trailing comma to the last entry.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a MyPy issue to request support for mypy.toml or similar: python/mypy#18617

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it shortly, sorry for the , bug 😢
I've fixed it several times already, but it is very persistent for some reason.

pretty = True

# Make sure Python can still be built
Expand Down