FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131507: Remove Misc/mypy symlinks from the repository by ambv · Pull Request #132270 · python/cpython · GitHub

/ cpython Public
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .in  (1) .md  (1) .py  (2) .yml  (1) No extension  (1) dotfile  (1) All 6 file types selected
Only manifest files
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions .github/workflows/mypy.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ jobs:
cache: pip
cache-dependency-path: Tools/requirements-dev.txt
- run: pip install -r Tools/requirements-dev.txt
- run: python3 Misc/mypy/make_symlinks.py
- run: mypy --config-file ${{ matrix.target }}/mypy.ini
1 change: 1 addition & 0 deletions Makefile.pre.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3206,6 +3206,7 @@ distclean: clobber docclean
Modules/ld_so_aix Modules/python.exp Misc/python.pc \
Misc/python-embed.pc Misc/python-config.sh
-rm -f python*-gdb.py
-find Misc/mypy -type l -delete
# Issue #28258: set LC_ALL to avoid issues with Estonian locale.
# Expansion is performed here by shell (spawned by make) itself before
# arguments are passed to find. So LC_ALL=C must be set as a separate
Expand Down
5 changes: 5 additions & 0 deletions Misc/mypy/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This list is also used in make_symlinks.py, only put actual concrete paths below

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's a pity .gitignore doesn't let you include other files.

# (no wildcards!).

_colorize.py
_pyrepl
15 changes: 13 additions & 2 deletions Misc/mypy/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ like `types`, `typing`, and `collections.abc`.

So instead, we set `mypy_path` to include this directory,
which only links modules and packages we know are safe to be
type-checked themselves and used as dependencies.
type-checked themselves and used as dependencies. See
`Lib/_pyrepl/mypy.ini` for an example.

See `Lib/_pyrepl/mypy.ini` for an example.
At the same time, we don't want symlinks to be checked into the
repository as they would end up being shipped as part of the source
tarballs, which can create compatibility issues with unpacking on
operating systems without symlink support. Additionally, those symlinks
would have to be part of the SBOM, which we don't want either.

Instead, this directory ships with a `make_symlinks.py` script, which

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

FWIW, I would be inclined to not symlink anything, and instead copy files to a separate directory to run mypy on... but then I don't use mypy and I have no idea how that would integrate with normal edit-typecheck workflows people have.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

copying files makes it annoying for a local workflow since then you have to copy the tree for every mypy run. that's too slow.

creates the symlinks when they are needed. This happens automatically
on GitHub Actions. You will have to run it manually for a local
type-checking workflow. Note that `make distclean` removes the symlinks
to ensure that the produced distribution is clean.
1 change: 0 additions & 1 deletion Misc/mypy/_colorize.py

This file was deleted.

1 change: 0 additions & 1 deletion Misc/mypy/_pyrepl

This file was deleted.

55 changes: 55 additions & 0 deletions Misc/mypy/make_symlinks.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
from __future__ import annotations

import argparse
import os
from pathlib import Path

CURRENT_DIR = Path(__file__).parent
MISC_DIR = CURRENT_DIR.parent
REPO_ROOT = MISC_DIR.parent
LIB_DIR = REPO_ROOT / "Lib"

parser = argparse.ArgumentParser(prog="make_symlinks.py")
parser.add_argument(
"--dry-run",
action="store_true",
help="Don't actually symlink or delete anything",
)
parser.add_argument(
"--force",
action="store_true",
help="Delete destination paths if they exist",
)

args = parser.parse_args()

for link in (CURRENT_DIR / ".gitignore").read_text().splitlines():
link = link.strip()
if not link or link.startswith('#'):
continue

src = LIB_DIR / link
dst = CURRENT_DIR / link
src_at_root = src.relative_to(REPO_ROOT)
dst_at_root = dst.relative_to(REPO_ROOT)
if args.force:
if dst.exists():
if args.dry_run:
print(f"{dst_at_root} already exists, would delete")
else:
print(f"{dst_at_root} already exists, deleting")
dst.unlink()
elif (
dst.is_symlink()
and src.resolve(strict=True) == dst.resolve(strict=True)
):
print(f"{dst_at_root} already exists, skipping")
continue

# we specifically want relative path links with ..
src_rel = os.path.relpath(src, CURRENT_DIR)
action = "symlinking" if not args.dry_run else "would symlink"
print(f"{action} {src_at_root} at {dst_at_root}")
if not args.dry_run:
os.symlink(src_rel, dst)

Back | FazBrowse Home | New Git URL