fix mypy 0.930 errors
This commit is contained in:
		
							parent
							
								
									cbccc06302
								
							
						
					
					
						commit
						b0aabe4081
					
				| 
						 | 
				
			
			@ -1429,6 +1429,7 @@ class Config:
 | 
			
		|||
            )
 | 
			
		||||
        except KeyError:
 | 
			
		||||
            return None
 | 
			
		||||
        assert mod.__file__ is not None
 | 
			
		||||
        modpath = Path(mod.__file__).parent
 | 
			
		||||
        values: List[Path] = []
 | 
			
		||||
        for relroot in relroots:
 | 
			
		||||
| 
						 | 
				
			
			@ -1574,7 +1575,7 @@ def _strtobool(val: str) -> bool:
 | 
			
		|||
@lru_cache(maxsize=50)
 | 
			
		||||
def parse_warning_filter(
 | 
			
		||||
    arg: str, *, escape: bool
 | 
			
		||||
) -> Tuple[str, str, Type[Warning], str, int]:
 | 
			
		||||
) -> Tuple["warnings._ActionKind", str, Type[Warning], str, int]:
 | 
			
		||||
    """Parse a warnings filter string.
 | 
			
		||||
 | 
			
		||||
    This is copied from warnings._setoption with the following changes:
 | 
			
		||||
| 
						 | 
				
			
			@ -1616,7 +1617,7 @@ def parse_warning_filter(
 | 
			
		|||
        parts.append("")
 | 
			
		||||
    action_, message, category_, module, lineno_ = (s.strip() for s in parts)
 | 
			
		||||
    try:
 | 
			
		||||
        action: str = warnings._getaction(action_)  # type: ignore[attr-defined]
 | 
			
		||||
        action: "warnings._ActionKind" = warnings._getaction(action_)  # type: ignore[attr-defined]
 | 
			
		||||
    except warnings._OptionError as e:
 | 
			
		||||
        raise UsageError(error_template.format(error=str(e)))
 | 
			
		||||
    try:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ def resolve(name: str) -> object:
 | 
			
		|||
    parts = name.split(".")
 | 
			
		||||
 | 
			
		||||
    used = parts.pop(0)
 | 
			
		||||
    found = __import__(used)
 | 
			
		||||
    found: object = __import__(used)
 | 
			
		||||
    for part in parts:
 | 
			
		||||
        used += "." + part
 | 
			
		||||
        try:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -539,6 +539,9 @@ def import_path(
 | 
			
		|||
    ignore = os.environ.get("PY_IGNORE_IMPORTMISMATCH", "")
 | 
			
		||||
    if ignore != "1":
 | 
			
		||||
        module_file = mod.__file__
 | 
			
		||||
        if module_file is None:
 | 
			
		||||
            raise ImportPathMismatchError(module_name, module_file, path)
 | 
			
		||||
 | 
			
		||||
        if module_file.endswith((".pyc", ".pyo")):
 | 
			
		||||
            module_file = module_file[:-1]
 | 
			
		||||
        if module_file.endswith(os.path.sep + "__init__.py"):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -330,6 +330,7 @@ class PyobjMixin(nodes.Node):
 | 
			
		|||
        if isinstance(compat_co_firstlineno, int):
 | 
			
		||||
            # nose compatibility
 | 
			
		||||
            file_path = sys.modules[obj.__module__].__file__
 | 
			
		||||
            assert file_path is not None
 | 
			
		||||
            if file_path.endswith(".pyc"):
 | 
			
		||||
                file_path = file_path[:-1]
 | 
			
		||||
            path: Union["os.PathLike[str]", str] = file_path
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -114,6 +114,7 @@ class TestConftestValueAccessGlobal:
 | 
			
		|||
            "a", startdir, importmode="prepend", rootpath=Path(basedir)
 | 
			
		||||
        )
 | 
			
		||||
        assert value == 1.5
 | 
			
		||||
        assert mod.__file__ is not None
 | 
			
		||||
        path = Path(mod.__file__)
 | 
			
		||||
        assert path.parent == basedir / "adir" / "b"
 | 
			
		||||
        assert path.stem == "conftest"
 | 
			
		||||
| 
						 | 
				
			
			@ -197,12 +198,14 @@ def test_conftestcutdir(pytester: Pytester) -> None:
 | 
			
		|||
    values = conftest._getconftestmodules(
 | 
			
		||||
        conf.parent, importmode="prepend", rootpath=pytester.path
 | 
			
		||||
    )
 | 
			
		||||
    assert values[0].__file__ is not None
 | 
			
		||||
    assert values[0].__file__.startswith(str(conf))
 | 
			
		||||
    # and all sub paths get updated properly
 | 
			
		||||
    values = conftest._getconftestmodules(
 | 
			
		||||
        p, importmode="prepend", rootpath=pytester.path
 | 
			
		||||
    )
 | 
			
		||||
    assert len(values) == 1
 | 
			
		||||
    assert values[0].__file__ is not None
 | 
			
		||||
    assert values[0].__file__.startswith(str(conf))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -214,6 +217,7 @@ def test_conftestcutdir_inplace_considered(pytester: Pytester) -> None:
 | 
			
		|||
        conf.parent, importmode="prepend", rootpath=pytester.path
 | 
			
		||||
    )
 | 
			
		||||
    assert len(values) == 1
 | 
			
		||||
    assert values[0].__file__ is not None
 | 
			
		||||
    assert values[0].__file__.startswith(str(conf))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -143,6 +143,10 @@ class TestImportPath:
 | 
			
		|||
        assert obj.x == 42  # type: ignore[attr-defined]
 | 
			
		||||
        assert obj.__name__ == "execfile"
 | 
			
		||||
 | 
			
		||||
    def test_import_path_missing_file(self, path1: Path) -> None:
 | 
			
		||||
        with pytest.raises(ImportPathMismatchError):
 | 
			
		||||
            import_path(path1 / "sampledir", root=path1)
 | 
			
		||||
 | 
			
		||||
    def test_renamed_dir_creates_mismatch(
 | 
			
		||||
        self, tmp_path: Path, monkeypatch: MonkeyPatch
 | 
			
		||||
    ) -> None:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue