Skip to content

Commit

Permalink
Merge pull request #10497 from pytest-dev/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
asottile committed Nov 16, 2022
2 parents cca029d + d5466b3 commit 66b2891
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:
- id: reorder-python-imports
args: ['--application-directories=.:src', --py37-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py37-plus]
Expand All @@ -58,7 +58,7 @@ repos:
hooks:
- id: python-use-type-annotations
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v0.990
hooks:
- id: mypy
files: ^(src/|testing/)
Expand Down
11 changes: 6 additions & 5 deletions src/_pytest/_py/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from stat import S_ISREG
from typing import Any
from typing import Callable
from typing import cast
from typing import overload
from typing import TYPE_CHECKING

Expand Down Expand Up @@ -146,7 +147,7 @@ def __init__(self, fil, rec, ignore, bf, sort):
self.fil = fil
self.ignore = ignore
self.breadthfirst = bf
self.optsort = sort and sorted or (lambda x: x)
self.optsort = cast(Callable[[Any], Any], sorted) if sort else (lambda x: x)

def gen(self, path):
try:
Expand Down Expand Up @@ -224,7 +225,7 @@ def owner(self):
raise NotImplementedError("XXX win32")
import pwd

entry = error.checked_call(pwd.getpwuid, self.uid)
entry = error.checked_call(pwd.getpwuid, self.uid) # type:ignore[attr-defined]
return entry[0]

@property
Expand All @@ -234,7 +235,7 @@ def group(self):
raise NotImplementedError("XXX win32")
import grp

entry = error.checked_call(grp.getgrgid, self.gid)
entry = error.checked_call(grp.getgrgid, self.gid) # type:ignore[attr-defined]
return entry[0]

def isdir(self):
Expand All @@ -252,15 +253,15 @@ def getuserid(user):
import pwd

if not isinstance(user, int):
user = pwd.getpwnam(user)[2]
user = pwd.getpwnam(user)[2] # type:ignore[attr-defined]
return user


def getgroupid(group):
import grp

if not isinstance(group, int):
group = grp.getgrnam(group)[2]
group = grp.getgrnam(group)[2] # type:ignore[attr-defined]
return group


Expand Down
10 changes: 6 additions & 4 deletions src/_pytest/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def pytest_assertion_pass(item: "Item", lineno: int, orig: str, expl: str) -> No
# -------------------------------------------------------------------------


def pytest_report_header(
def pytest_report_header( # type:ignore[empty-body]
config: "Config", start_path: Path, startdir: "LEGACY_PATH"
) -> Union[str, List[str]]:
"""Return a string or list of strings to be displayed as header info for terminal reporting.
Expand Down Expand Up @@ -767,7 +767,7 @@ def pytest_report_header(
"""


def pytest_report_collectionfinish(
def pytest_report_collectionfinish( # type:ignore[empty-body]
config: "Config",
start_path: Path,
startdir: "LEGACY_PATH",
Expand Down Expand Up @@ -800,7 +800,7 @@ def pytest_report_collectionfinish(


@hookspec(firstresult=True)
def pytest_report_teststatus(
def pytest_report_teststatus( # type:ignore[empty-body]
report: Union["CollectReport", "TestReport"], config: "Config"
) -> Tuple[str, str, Union[str, Mapping[str, bool]]]:
"""Return result-category, shortletter and verbose word for status
Expand Down Expand Up @@ -880,7 +880,9 @@ def pytest_warning_recorded(
# -------------------------------------------------------------------------


def pytest_markeval_namespace(config: "Config") -> Dict[str, Any]:
def pytest_markeval_namespace( # type:ignore[empty-body]
config: "Config",
) -> Dict[str, Any]:
"""Called when constructing the globals dictionary used for
evaluating string conditions in xfail/skipif markers.
Expand Down
6 changes: 3 additions & 3 deletions testing/_py/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def test_long_filenames(self, tmpdir):
# depending on how the paths are used), but > 4096 (which is the
# Linux' limitation) - the behaviour of paths with names > 4096 chars
# is undetermined
newfilename = "/test" * 60
newfilename = "/test" * 60 # type:ignore[unreachable]
l1 = tmpdir.join(newfilename)
l1.ensure(file=True)
l1.write("foo")
Expand Down Expand Up @@ -1344,8 +1344,8 @@ def test_realpath_file(self, tmpdir):
assert realpath.basename == "file"

def test_owner(self, path1, tmpdir):
from pwd import getpwuid
from grp import getgrgid
from pwd import getpwuid # type:ignore[attr-defined]
from grp import getgrgid # type:ignore[attr-defined]

stat = path1.stat()
assert stat.path == path1
Expand Down
2 changes: 1 addition & 1 deletion testing/test_monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_delattr(self, monkeypatch: MonkeyPatch) -> None:
mp.delattr("os.path.abspath")
assert not hasattr(os.path, "abspath")
mp.undo()
assert os.path.abspath
assert os.path.abspath # type:ignore[truthy-function]


def test_delattr() -> None:
Expand Down

0 comments on commit 66b2891

Please sign in to comment.