{"record":{"id":"1d580f291a16700e","repo":"apache/beam","slug":"pyrefly-exited-with-status-d","errorCode":null,"errorMessage":"pyrefly exited with status %d","messagePattern":"pyrefly exited with status (.+?)","errorType":"exception","errorClass":"DistutilsError","httpStatus":null,"severity":"error","filePath":"sdks/python/setup.py","lineNumber":77,"sourceCode":"    \"\"\"Abstract method that is required to be overwritten\"\"\"\n\n  def get_project_path(self):\n    self.run_command('egg_info')\n\n    # Build extensions in-place\n    self.reinitialize_command('build_ext', inplace=1)\n    self.run_command('build_ext')\n\n    ei_cmd = self.get_finalized_command(\"egg_info\")\n\n    project_path = normalize_path(ei_cmd.egg_base)\n    return os.path.join(project_path, to_filename(ei_cmd.egg_name))\n\n  def run(self):\n    args = ['pyrefly', 'check', self.get_project_path()]\n    result = subprocess.call(args)\n    if result != 0:\n      raise DistutilsError(\"pyrefly exited with status %d\" % result)\n\n\ndef get_version():\n  global_names = {}\n  exec(  # pylint: disable=exec-used\n      open(os.path.join(\n          os.path.dirname(os.path.abspath(__file__)),\n          'apache_beam/version.py')\n          ).read(),\n      global_names\n  )\n  return global_names['__version__']\n\n\nPACKAGE_NAME = 'apache-beam'\nPACKAGE_VERSION = get_version()\nPACKAGE_DESCRIPTION = 'Apache Beam SDK for Python'\nPACKAGE_URL = 'https://beam.apache.org'","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/setup.py#L59-L95","documentation":"setup.py's pyrefly check command runs the external `pyrefly` type checker against the project path via subprocess.call and raises DistutilsError whenever pyrefly's exit status is nonzero, i.e. pyrefly reported type errors or failed to run. This blocks the packaging step so type errors cannot be silently released.","triggerScenarios":"Running `python setup.py pyrefly_check` (or a build that invokes it) when pyrefly check finds type errors in apache_beam, or when the pyrefly binary is missing/old (subprocess.call returns a nonzero status or the shell returns 127).","commonSituations":"Developers adding code that fails pyrefly checks; pyrefly not installed on the machine (command not found yields nonzero status); CI pins an older pyrefly that doesn't support new syntax.","solutions":["Run `pyrefly check .` locally and fix the reported type errors","Install or upgrade pyrefly so the binary is on PATH (`pip install pyrefly`)","Confirm the project path passed to check is correct in get_project_path()","Temporarily skip the check target if you only need sdist/wheel without type gating"],"exampleFix":"# before\n$ python setup.py pyrefly_check\nDistutilsError: pyrefly exited with status 1\n# after\n$ pyrefly check .   # fix reported errors first\n$ python setup.py pyrefly_check   # succeeds","handlingStrategy":"try-catch","validationCode":"import shutil\nif shutil.which('pyrefly') is None:\n    raise RuntimeError('pyrefly not installed; pip install pyrefly')","typeGuard":null,"tryCatchPattern":"try:\n    result = subprocess.call(['pyrefly', 'check', project_path])\nexcept DistutilsError as e:\n    if 'pyrefly exited with status' in str(e):\n        fix_type_errors_or_install_pyrefly()\n    else:\n        raise","preventionTips":["Run pyrefly check locally before packaging","Keep pyrefly installed and on PATH in dev/CI images","Pin pyrefly version in dev requirements"],"tags":["python","type-checking","setup-py","subprocess"],"backgroundTag":"type-check-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}