Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[meta] Better error messages dumpyard #11

Open
pradyunsg opened this issue Oct 16, 2021 · 1 comment
Open

[meta] Better error messages dumpyard #11

pradyunsg opened this issue Oct 16, 2021 · 1 comment

Comments

@pradyunsg
Copy link
Owner

No description provided.

Repository owner locked as off-topic and limited conversation to collaborators Oct 16, 2021
@pradyunsg
Copy link
Owner Author

Remaining raises to triage

src/pip/_internal/operations/install/legacy.py:
   46          ).format(req_description)
   47:         raise InstallationError(message)
   48  

  113              # Signal to the caller that we didn't install the new package
  114:             raise LegacyInstallFailure from e
  115  

src/pip/_internal/operations/install/wheel.py:
  420      if entry is not None and entry.suffix is None:
  421:         raise MissingCallableSuffix(str(entry))
  422  

  487              )
  488:             raise InstallationError(
  489                  message.format(wheel_path, target_path, dest_dir_path)

  516                  ).format(wheel_path, record_path)
  517:                 raise InstallationError(message)
  518  

  527                  ).format(wheel_path, scheme_key, record_path, valid_scheme_keys)
  528:                 raise InstallationError(message)
  529  

  713          message = "For req: {}. {}".format(req_description, e.args[0])
  714:         raise InstallationError(message) from e
  715  

src/pip/_internal/req/constructors.py:
  100          backends = ", ".join(vcs.all_schemes)
  101:         raise InstallationError(
  102              f"{editable_req} is not a valid editable requirement. "

  108      if not package_name:
  109:         raise InstallationError(
  110              "Could not detect requirement name for '{}', please specify one "

  164          except InvalidRequirement:
  165:             raise InstallationError(f"Invalid requirement: '{name}'")
  166      else:

  237              return path_to_url(path)
  238:         raise InstallationError(
  239              f"Directory {name!r} is not installable. Neither 'setup.py' "

  292          if link.is_wheel:
  293:             wheel = Wheel(link.filename)  # can raise InvalidWheelFilename
  294              req_as_string = f"{wheel.name}=={wheel.version}"

  326                  msg += f"\nHint: {add_msg}"
  327:             raise InstallationError(msg)
  328          else:

  336                      msg = f"Extras after version '{spec_str}'."
  337:                     raise InstallationError(msg)
  338          return req

  391      except InvalidRequirement:
  392:         raise InstallationError(f"Invalid requirement: '{req_string}'")
  393  

  404          # Explicitly disallow pypi packages that depend on external urls
  405:         raise InstallationError(
  406              "Packages installed from PyPI cannot depend on packages "

src/pip/_internal/req/req_file.py:
  369                  msg = f"Invalid requirement: {line}\n{e.msg}"
  370:                 raise RequirementsFileParseError(msg)
  371  

  435      def parser_exit(self: Any, msg: str) -> "NoReturn":
  436:         raise OptionParsingError(msg)
  437  

  534      except OSError as exc:
  535:         raise InstallationError(f"Could not open requirements file: {exc}")
  536      return url, content

src/pip/_internal/req/req_install.py:
  429                  ):
  430:                     raise InstallationError(
  431                          "Will not install to the user site because it will "

  519                  ):
  520:                     raise InstallationError(
  521                          f"Project {self} has a 'pyproject.toml' and its build "

  539          ):
  540:             raise InstallationError(
  541                  f"File 'setup.py' or 'setup.cfg' not found "

  563              except HookMissing as e:
  564:                 raise InstallationError(
  565                      f"Project {self} has a pyproject.toml but its build "

  568          elif not os.path.exists(self.setup_py_path):
  569:             raise InstallationError(
  570                  f"File 'setup.py' not found for legacy project {self}."

  868              self.install_succeeded = False
  869:             raise exc.__cause__
  870          except Exception:

src/pip/_internal/req/req_set.py:
   82  
   83:         # If the wheel is not supported, raise an error.
   84          # Should check this after filtering out based on environment markers to

   90              if self.check_supported_wheels and not wheel.supported(tags):
   91:                 raise InstallationError(
   92                      "{} is not a supported wheel on this platform.".format(

  124          if has_conflicting_requirement:
  125:             raise InstallationError(
  126                  "Double requirement given: {} (already in {}, name={!r})".format(

  146          if does_not_satisfy_constraint:
  147:             raise InstallationError(
  148                  "Could not satisfy constraints for '{}': "

  184  
  185:         raise KeyError(f"No project with the name {name!r}")
  186  

src/pip/_internal/req/req_tracker.py:
  91              message = "{} is already being built: {}".format(req.link, contents)
  92:             raise LookupError(message)
  93  

src/pip/_internal/req/req_uninstall.py:
   85              if not installer or installer == "pip":
   86:                 raise ValueError()
   87          except (OSError, StopIteration, ValueError):

   94              msg += " Hint: The package was installed by {}.".format(installer)
   95:         raise UninstallationError(msg) from missing_record_exception
   96      for row in r:

  505          elif distutils_egg_info:
  506:             raise UninstallationError(
  507                  "Cannot uninstall {!r}. It is a distutils installed project "

src/pip/_internal/resolution/legacy/resolver.py:
   76      except FileNotFoundError as e:
   77:         raise NoneMetadataError(dist, str(e))
   78      try:

  101  
  102:     raise UnsupportedPythonVersion(
  103          "Package {!r} requires a different Python: {} not in {!r}".format(

  186          if hash_errors:
  187:             raise hash_errors
  188  

  257                  # be raised later when we re-try later to do the install.
  258:                 # Why don't we just raise here?
  259                  pass

  379          dist = self._get_dist_for(req_to_install)
  380:         # This will raise UnsupportedPythonVersion if the given Python
  381          # version isn't compatible with the distribution's Requires-Python.

src/pip/_internal/resolution/resolvelib/candidates.py:
  208          if self._name is not None and self._name != dist.canonical_name:
  209:             raise MetadataInconsistent(
  210                  self._ireq,

  215          if self._version is not None and self._version != dist.version:
  216:             raise MetadataInconsistent(
  217                  self._ireq,

src/pip/_internal/resolution/resolvelib/factory.py:
  138          msg = f"{link.filename} is not a supported wheel on this platform."
  139:         raise UnsupportedWheel(msg)
  140  

  441              # can make the resolver do the right thing, either backtrack (and
  442:             # maybe find some other requirement that's buildable) or raise a
  443              # ResolutionImpossible eventually.
  444              if not ireq.name:
  445:                 raise self._build_failures[ireq.link]
  446              return UnsatisfiableRequirement(canonicalize_name(ireq.name))

  457                  if problem:
  458:                     raise InstallationError(problem)
  459                  if not ireq.match_markers():

  547              )
  548:             raise InstallationError(message)
  549          return None

src/pip/_internal/resolution/resolvelib/resolver.py:
  100              )
  101:             raise error from e
  102  

src/pip/_internal/utils/compat.py:
  48          else:
  49:             # raise OSError for parity with os.O_NOFOLLOW above
  50:             raise OSError(f"{path} is a symlink; Will not return uid for symlinks")
  51      return file_uid

src/pip/_internal/utils/deprecation.py:
  115  
  116:     # Raise as an error if this behaviour is deprecated.
  117      if is_gone:
  118:         raise PipDeprecationWarning(message)
  119  

src/pip/_internal/utils/filesystem.py:
   62                  if is_socket_file:
   63:                     raise shutil.SpecialFileError(f"`{f}` is a socket")
   64  

   96  
   97: # Tenacity raises RetryError by default, explicitly raise the original exception
   98  _replace_retry = retry(reraise=True, stop=stop_after_delay(1), wait=wait_fixed(0.25))

  147      # This should never be reached
  148:     raise OSError("Unexpected condition testing for writable directory")
  149  

src/pip/_internal/utils/hashes.py:
   73  
   74:         Raise HashMismatch if none match.
   75  

   81              except (ValueError, TypeError):
   82:                 raise InstallationError(f"Unknown hash name: {hash_name}")
   83  

   93      def _raise(self, gots: Dict[str, "_Hash"]) -> "NoReturn":
   94:         raise HashMismatch(self._allowed, gots)
   95  

   98  
   99:         Raise HashMismatch if none match.
  100  

  143      def _raise(self, gots: Dict[str, "_Hash"]) -> "NoReturn":
  144:         raise HashMissing(gots[FAVORITE_HASH].hexdigest())

src/pip/_internal/utils/logging.py:
  195          # If a broken pipe occurred while calling write() or flush() on the
  196:         # stdout stream in logging's Handler.emit(), then raise our special
  197          # exception so we can handle it in main() instead of logging the

  204          ):
  205:             raise BrokenStdoutLoggingError()
  206  

src/pip/_internal/utils/misc.py:
  104      except OSError as e:
  105:         # Windows can raise spurious ENOTEMPTY errors. See #6426.
  106          if e.errno != errno.EEXIST and e.errno != errno.ENOTEMPTY:

  122  # Retry every half second for up to 3 seconds
  123: # Tenacity raises RetryError by default, explicitly raise the original exception
  124  @retry(reraise=True, stop=stop_after_delay(3), wait=wait_fixed(0.5))

  176  def _check_no_input(message: str) -> None:
  177:     """Raise an error if no input is allowed."""
  178      if os.environ.get("PIP_NO_INPUT"):
  179:         raise Exception(
  180              f"No input was expected ($PIP_NO_INPUT set); question: {message}"

  223      else:
  224:         raise ValueError(f"invalid truth value {val!r}")
  225  

  630          new_command = [sys.executable, "-m", "pip"] + sys.argv[1:]
  631:         raise CommandError(
  632              "To modify pip, please run the following command:\n{}".format(

src/pip/_internal/utils/packaging.py:
  58      if metadata is None:
  59:         raise NoneMetadataError(dist, metadata_name)
  60  

src/pip/_internal/utils/subprocess.py:
  253                  subprocess_logger.error(msg)
  254:             raise InstallationSubprocessError(proc.returncode, command_desc)
  255          elif on_returncode == "warn":

  264          else:
  265:             raise ValueError(f"Invalid value: on_returncode={on_returncode!r}")
  266      return output

src/pip/_internal/utils/unpacking.py:
  128                  )
  129:                 raise InstallationError(message.format(filename, fn, location))
  130              if fn.endswith("/") or fn.endswith("\\"):

  185                  )
  186:                 raise InstallationError(message.format(filename, path, location))
  187              if member.isdir():

  257          )
  258:         raise InstallationError(f"Cannot determine archive format of {location}")

src/pip/_internal/utils/urls.py:
  42      else:
  43:         raise ValueError(
  44              f"non-local file URIs are not supported on this platform: {url!r}"

src/pip/_internal/utils/wheel.py:
   35              # Augment the default error with the origin of the file.
   36:             raise UnsupportedWheel(
   37                  f"Error decoding metadata for {self._wheel_name}: {e}"

   58          except UnsupportedWheel as e:
   59:             raise UnsupportedWheel("{} has an invalid wheel, {}".format(name, str(e)))
   60  

   76      except UnsupportedWheel as e:
   77:         raise UnsupportedWheel("{} has an invalid wheel, {}".format(name, str(e)))
   78  

   95      if not info_dirs:
   96:         raise UnsupportedWheel(".dist-info directory not found")
   97  
   98      if len(info_dirs) > 1:
   99:         raise UnsupportedWheel(
  100              "multiple .dist-info directories found: {}".format(", ".join(info_dirs))

  107      if not info_dir_name.startswith(canonical_name):
  108:         raise UnsupportedWheel(
  109              ".dist-info directory {!r} does not start with {!r}".format(

  122      except (BadZipFile, KeyError, RuntimeError) as e:
  123:         raise UnsupportedWheel(f"could not read {path!r} file: {e!r}")
  124  

  127      """Return the WHEEL metadata of an extracted wheel, if possible.
  128:     Otherwise, raise UnsupportedWheel.
  129      """

  136      except UnicodeDecodeError as e:
  137:         raise UnsupportedWheel(f"error decoding {path!r}: {e!r}")
  138  
  139:     # FeedParser (used by Parser) does not raise any exceptions. The returned
  140      # message may have .defects populated, but for backwards-compatibility we

  146      """Given WHEEL metadata, return the parsed Wheel-Version.
  147:     Otherwise, raise UnsupportedWheel.
  148      """

  150      if version_text is None:
  151:         raise UnsupportedWheel("WHEEL is missing Wheel-Version")
  152  

  157      except ValueError:
  158:         raise UnsupportedWheel(f"invalid Wheel-Version: {version!r}")
  159  

  168      version: a 2-tuple representing a Wheel-Version (Major, Minor)
  169:     name: name of wheel or package to raise exception about
  170  

  173      if version[0] > VERSION_COMPATIBLE[0]:
  174:         raise UnsupportedWheel(
  175              "{}'s Wheel-Version ({}) is not compatible with this version "

src/pip/_internal/vcs/bazaar.py:
  74                      return repo
  75:         raise RemoteNotFoundError
  76  

src/pip/_internal/vcs/git.py:
  156                  # this error ever occurs.
  157:                 raise ValueError(f"unexpected show-ref line: {line!r}")
  158  

  355          except IndexError:
  356:             raise RemoteNotFoundError
  357  

  393          # Otherwise, bail out.
  394:         raise RemoteNotValidError(url)
  395  

src/pip/_internal/vcs/subversion.py:
  123                  )
  124:                 raise RemoteNotFoundError
  125  

  127          if url is None:
  128:             raise RemoteNotFoundError
  129  

  151              if not match:
  152:                 raise ValueError(f"Badly formatted data: {data!r}")
  153              url = match.group(1)  # get repository URL

src/pip/_internal/vcs/versioncontrol.py:
  401          if "+" not in scheme:
  402:             raise ValueError(
  403                  "Sorry, {!r} is a malformed VCS url. "

  413              if not rev:
  414:                 raise InstallationError(
  415                      "The URL {!r} has an empty revision (after @) "

  653              # In other words, the VCS executable isn't available
  654:             raise BadCommand(
  655                  f"Cannot find command {cls.name!r} - do you have "

  662              # permission to call the other user command.
  663:             raise BadCommand(
  664                  f"No permission to execute {cls.name!r} - install it "

tests/conftest.py:
  111          else:
  112:             raise RuntimeError(f"Unknown test type (filename = {module_path})")
  113  

tests/data/packages/BrokenEmitsUTF8/setup.py:
  31  
  32:     raise FakeError("this package designed to fail on install")
  33  

tests/data/packages/pep517_wrapper_buildsys/mybuildsys.py:
  13      if os.environ.get("PIP_TEST_FAIL_BUILD_WHEEL"):
  14:         raise RuntimeError("Failing build_wheel, as requested.")
  15  

tests/functional/test_broken_stdout.py:
  36      # Check that no traceback occurs.
  37:     assert "raise BrokenStdoutLoggingError()" not in stderr
  38      assert stderr.count("Traceback") == 0

  53      # Check that no traceback occurs.
  54:     assert "raise BrokenStdoutLoggingError()" not in stderr
  55      assert stderr.count("Traceback") == 0

  70      # We permit up to two because the exception can be chained.
  71:     assert "raise BrokenStdoutLoggingError()" in stderr
  72      assert 1 <= stderr.count("Traceback") <= 2

tests/functional/test_cache.py:
  370  def test_cache_purge_too_many_args(script, http_cache_files, wheel_cache_files):
  371:     """Running `pip cache purge aaa` should raise an error and remove no
  372      cached http files or wheels."""

tests/functional/test_install.py:
   46          with open(setuptools_mod, "a") as f:
   47:             f.write('\nraise ImportError("toto")')
   48      else:
   49:         raise ValueError(variant)
   50      script.pip(

   67      with open(script.scratch_path / "pip.py", "w") as fp:
   68:         fp.write("raise ImportError")
   69      script.run(

  159      with open(system_pip_dir / "__init__.py", "w") as fp:
  160:         fp.write("raise ImportError\n")
  161      script.pip(

  904      Test that installing package to usersite with target
  905:     must raise error
  906      """

tests/functional/test_pep517.py:
  201              "else:\n"
  202:             '    raise RuntimeError("Source dir incorrectly on sys.path")\n'
  203          )

tests/lib/__init__.py:
  294              if egg_link_path in self.files_created:
  295:                 raise TestFailure(
  296                      f"unexpected egg link file created: {egg_link_path!r}\n{self}"

  299              if egg_link_path not in self.files_created:
  300:                 raise TestFailure(
  301                      f"expected egg link file missing: {egg_link_path!r}\n{self}"

  312                  expected_ending = pkg_dir + "\n."
  313:                 raise TestFailure(
  314                      textwrap.dedent(

  331              maybe = "" if without_egg_link else "not "
  332:             raise TestFailure(f"{pth_file} unexpectedly {maybe}updated by install")
  333  

  336              files = sorted(self.files_created)
  337:             raise TestFailure(
  338                  textwrap.dedent(

  349              if normalized_path not in self.files_created:
  350:                 raise TestFailure(
  351                      f"Package directory {pkg_dir!r} missing expected content {f!r}"

  356              if normalized_path in self.files_created:
  357:                 raise TestFailure(
  358                      f"Package directory {pkg_dir!r} has unexpected content {f}"

  423              msg = make_check_stderr_message(stderr, line=line, reason=reason)
  424:             raise RuntimeError(msg)
  425          if allow_stderr_error:

  433              msg = make_check_stderr_message(stderr, line=line, reason=reason)
  434:             raise RuntimeError(msg)
  435          if allow_stderr_warning:

  443              msg = make_check_stderr_message(stderr, line=line, reason=reason)
  444:             raise RuntimeError(msg)
  445  

  610              if allow_stderr_error is not None and not allow_stderr_error:
  611:                 raise RuntimeError(
  612                      "cannot pass allow_stderr_error=False with expect_error=True"

  618              if allow_stderr_warning is not None and not allow_stderr_warning:
  619:                 raise RuntimeError(
  620                      "cannot pass allow_stderr_warning=False with expect_stderr=True"

  625              if allow_stderr_warning is not None and not allow_stderr_warning:
  626:                 raise RuntimeError(
  627                      "cannot pass allow_stderr_warning=False with "

  644                  __tracebackhide__ = True
  645:                 raise AssertionError("Script passed unexpectedly.")
  646  

  781      if list(diff.values()) != [{}, {}, {}]:
  782:         raise TestFailure(
  783              "Unexpected changes:\n"

  896      else:
  897:         raise ValueError(f"Unknown vcs: {vcs}")
  898      return version_pkg_path

tests/lib/path.py:
  159      def join(self, parts: Iterable[str]) -> str:
  160:         raise RuntimeError("Path.join is invalid, use joinpath instead.")
  161  

tests/lib/server.py:
  86          except StopIteration:
  87:             raise RuntimeError("Ran out of mocked responses.")
  88          return responder(environ, start_response)

tests/unit/test_base_command.py:
  32              def run_func() -> int:
  33:                 raise SystemExit(1)
  34  

  66          def raise_broken_stdout() -> NoReturn:
  67:             raise BrokenStdoutLoggingError()
  68  

tests/unit/test_collector.py:
  65      `_get_html_response()` should send a HEAD request on an archive-like URL
  66:     if the scheme supports it, and raise `_NotHTML` if the response isn't HTML.
  67      """

tests/unit/test_network_auth.py:
  311          self._call_count += 1
  312:         raise Exception("This keyring is broken!")
  313  

tests/unit/test_req_install.py:
  59          Requirement strings that cannot be parsed by
  60:         packaging.requirements.Requirement raise an InstallationError.
  61          """

tests/unit/test_req.py:
  116      def test_no_reuse_existing_build_dir(self, data: TestData) -> None:
  117:         """Test prepare_files raise exception with previous build dir"""
  118  

  153      def test_missing_hash_with_require_hashes(self, data: TestData) -> None:
  154:         """Setting --require-hashes explicitly should raise errors if hashes
  155          are missing.

  188      def test_unsupported_hashes(self, data: TestData) -> None:
  189:         """VCS and dir links should raise errors when --require-hashes is
  190          on.

  266      def test_hash_mismatch(self, data: TestData) -> None:
  267:         """A hash mismatch should raise an error."""
  268          file_url = path_to_url((data.packages / "simple-1.0.tar.gz").resolve())

tests/unit/test_resolution_legacy_resolver.py:
  160              def metadata(self) -> email.message.Message:
  161:                 raise FileNotFoundError(metadata_name)
  162  

tests/unit/test_utils_parallel.py:
  33  def lack_sem_open(name: str, *args: Any, **kwargs: Any) -> Any:
  34:     """Raise ImportError on import of multiprocessing.synchronize."""
  35      if name.endswith("synchronize"):
  36:         raise ImportError
  37      return _import(name, *args, **kwargs)

tests/unit/test_utils_subprocess.py:
  235          if len(records) != len(expected_records):
  236:             raise RuntimeError(f"{records} != {expected_records}")
  237  

tests/unit/test_utils_temp_dir.py:
  186      def raising_mkdir(*args: Any, **kwargs: Any) -> None:
  187:         raise OSError("Unknown OSError")
  188  

tests/unit/test_utils.py:
  337      try:
  338:         raise RuntimeError("test message")
  339      except RuntimeError:

  350      """
  351:     Test wrapped rmtree doesn't raise an error
  352      by the given nonexistent directory.

  363          if time.time() < self.succeed_after:
  364:             raise OSError("Failed")
  365  

  475      def test_failure(self) -> None:
  476:         """Hashes should raise HashMismatch when no hashes match."""
  477          hashes = Hashes({"sha256": ["wrongwrong"]})

  481      def test_missing_hashes(self) -> None:
  482:         """MissingHashes should raise HashMissing when any check is done."""
  483          with pytest.raises(HashMissing):

  486      def test_unknown_hash(self) -> None:
  487:         """Hashes should raise InstallationError when it encounters an unknown
  488          hash."""

  553  def raises(error: Type[Exception]) -> NoReturn:
  554:     raise error
  555  

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant