Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 0 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ permissions:
contents: read

jobs:
mypy:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v7
- uses: jpetrucciani/mypy-check@master
with:
path: 'python/runfiles'
- uses: jpetrucciani/mypy-check@master
with:
path: 'tests/runfiles'
ruff:
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 5 additions & 5 deletions python/runfiles/runfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Path(pathlib.Path):
using the associated `Runfiles` instance when converted to a string.
"""

# Mypy isn't smart enough to realize `self` in the methods
# Static type checkers may not realize `self` in the methods
# refers to our Path class instead of pathlib.Path
_runfiles: Runfiles | None
_source_repo: str | None
Expand Down Expand Up @@ -231,8 +231,8 @@ def with_segments(self, *pathsegments: str | os.PathLike) -> Self:
# override
def _make_child(self, args: tuple[str, ...]) -> Self:
# _make_child is an internal CPython method in Python < 3.12 omitted from
# typeshed stubs. We ignore [misc] for mypy and [missing-attribute] for pyrefly.
obj = cast("Path", super()._make_child(args)) # type: ignore[misc] # pyrefly: ignore[missing-attribute]
# typeshed stubs. We ignore [missing-attribute] for pyrefly.
obj = cast("Path", super()._make_child(args)) # pyrefly: ignore[missing-attribute]
obj._runfiles = self._runfiles
obj._source_repo = self._source_repo
return cast(Self, obj)
Expand Down Expand Up @@ -378,13 +378,13 @@ def __str__(self) -> str:
path_posix = super().__str__().replace("\\", "/")
if not path_posix or path_posix == ".":
# pylint: disable=protected-access
return self._runfiles._python_runfiles_root # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute]
return self._runfiles._python_runfiles_root # pyrefly: ignore[missing-attribute]
resolved = self._runfiles.Rlocation(path_posix, source_repo=self._source_repo)
if resolved is not None:
return resolved

# pylint: disable=protected-access
return posixpath.join(self._runfiles._python_runfiles_root, path_posix) # type: ignore[attr-defined] # pyrefly: ignore[missing-attribute]
return posixpath.join(self._runfiles._python_runfiles_root, path_posix) # pyrefly: ignore[missing-attribute]

def __fspath__(self) -> str:
return str(self)
Expand Down
22 changes: 11 additions & 11 deletions tests/runfiles/runfiles_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class RunfilesTest(unittest.TestCase):

def testRlocationArgumentValidation(self) -> None:
r = runfiles.Create({"RUNFILES_DIR": "whatever"})
assert r is not None # mypy doesn't understand the unittest api.
self.assertRaises(ValueError, lambda: r.Rlocation(None)) # type: ignore[arg-type] # pyrefly: ignore[bad-argument-type]
assert r is not None # type assert
self.assertRaises(ValueError, lambda: r.Rlocation(None)) # pyrefly: ignore[bad-argument-type]
self.assertRaises(ValueError, lambda: r.Rlocation(""))
self.assertRaises(TypeError, lambda: r.Rlocation(1)) # type: ignore[arg-type] # pyrefly: ignore[bad-argument-type]
self.assertRaises(TypeError, lambda: r.Rlocation(1)) # pyrefly: ignore[bad-argument-type]
self.assertRaisesRegex(
ValueError, "is not normalized", lambda: r.Rlocation("../foo")
)
Expand Down Expand Up @@ -69,7 +69,7 @@ def testRlocationArgumentValidation(self) -> None:

def testRlocationWithData(self) -> None:
r = runfiles.Create()
assert r is not None # mypy doesn't understand the unittest api.
assert r is not None # type assert
settings_path = r.Rlocation(
"rules_python/tests/support/current_build_settings.json"
)
Expand All @@ -86,7 +86,7 @@ def testCreatesManifestBasedRunfiles(self) -> None:
"TEST_SRCDIR": "always ignored",
}
)
assert r is not None # mypy doesn't understand the unittest api.
assert r is not None # type assert
self.assertEqual(r.Rlocation("a/b"), "c/d")
self.assertIsNone(r.Rlocation("foo"))

Expand All @@ -98,7 +98,7 @@ def testManifestBasedRunfilesEnvVars(self) -> None:
"TEST_SRCDIR": "always ignored",
}
)
assert r is not None # mypy doesn't understand the unittest api.
assert r is not None # type assert
self.assertDictEqual(
r.EnvVars(),
{
Expand All @@ -115,7 +115,7 @@ def testManifestBasedRunfilesEnvVars(self) -> None:
"TEST_SRCDIR": "always ignored",
}
)
assert r is not None # mypy doesn't understand the unittest api.
assert r is not None # type assert
self.assertDictEqual(
r.EnvVars(),
{
Expand All @@ -136,7 +136,7 @@ def testManifestBasedRunfilesEnvVars(self) -> None:
"TEST_SRCDIR": "always ignored",
}
)
assert r is not None # mypy doesn't understand the unittest api.
assert r is not None # type assert
self.assertDictEqual(
r.EnvVars(),
{
Expand All @@ -153,7 +153,7 @@ def testCreatesDirectoryBasedRunfiles(self) -> None:
"TEST_SRCDIR": "always ignored",
}
)
assert r is not None # mypy doesn't understand the unittest api.
assert r is not None # type assert
self.assertEqual(r.Rlocation("a/b"), "runfiles/dir/a/b")
self.assertEqual(r.Rlocation("foo"), "runfiles/dir/foo")

Expand All @@ -164,7 +164,7 @@ def testDirectoryBasedRunfilesEnvVars(self) -> None:
"TEST_SRCDIR": "always ignored",
}
)
assert r is not None # mypy doesn't understand the unittest api.
assert r is not None # type assert
self.assertDictEqual(
r.EnvVars(),
{
Expand Down Expand Up @@ -763,7 +763,7 @@ def testCurrentRepository(self) -> None:
else:
expected = "rules_python"
r = runfiles.Create()
assert r is not None # mypy doesn't understand the unittest api.
assert r is not None # type assert
self.assertEqual(r.CurrentRepository(), expected)

@staticmethod
Expand Down