Enable all Pyright rules in pyproject.toml that would currently succeed

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • DevProd Test Infrastructure
    • Fully Compatible
    • DevProd Test Infra 2026-05-19, DevProd Test Infra 2026-06-02
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      All of the diagnostic rules in our pyproject.toml have been manually disabled, preventing us from catching problematic errors that might slip past code review.

      By modifying all pyproject.toml rules to "error" and running the following code partially generated by Glean, I was able to find all Pyright rules that we are not currently breaking (currently on master commit dated 17 Apr 2026):

      const { exec } = require('child_process');
      const fs = require('fs').promises;
      const os = require('os');
      const path = require('path');
      
      function runBazelLintAll() {
      	return new Promise((resolve) => {
      		exec(
      			'echo $(test -f /tmp/bazel-run-lint-output.txt' +
      				' && ' +
      				'cat /tmp/bazel-run-lint-output.txt' +
      				' || ' +
      				'echo' +
      				' $(bazel run lint --all 2>&1 | tee /tmp/bazel-run-lint-output.txt) ' +
      				')',
      			{ maxBuffer: 100 * 1024 * 1024 }, // bump if output is huge
      			(_, stdout, stderr) => {
      				resolve(stdout + stderr);
      			}
      		);
      	});
      }
      
      const extractReportTokens = (text) => new Set(text.match(/report[A-Z]\w+/g) || []);
      
      const main = async function (mongo_dir = path.join(os.homedir(), 'mongo')) {
      	const bazelReports = extractReportTokens(await runBazelLintAll());
      
      	const pyprojectReports = await (async () => {
      		const pyprojectPath = path.join(mongo_dir, 'pyproject.toml');
      		return extractReportTokens(await fs.readFile(pyprojectPath, 'utf8'));
      	})();
      
      	const pyMinusBazel = [...pyprojectReports].filter((x) => !bazelReports.has(x));
      
      	console.log('In pyproject.toml but not in bazel lint output:');
      	pyMinusBazel.forEach((ent) => console.log(`\t${ent}`);
      };
      
      main().catch((err) => {
      	console.error(err);
      	process.exit(1);
      });
      
      /** 
       * In pyproject.toml but not in bazel lint output:
       *         reportAbstractUsage
       *         reportAssertTypeFailure
       *         reportInconsistentOverload
       *         reportNoOverloadImplementation
       *         reportOptionalContextManager
       *         reportUnusedCoroutine
       *         reportUnusedExcept
       *         reportOverlappingOverload
       *         reportAssertAlwaysTrue
       *         reportInvalidStringEscapeSequence
       *         reportInvalidTypeVarUse
       *         reportUnsupportedDunderAll
       *         reportUnusedExpression
       *         reportWildcardImportFromLibrary
       */
      

      Enabling these rules would stop us from breaking them in the future, without requiring any actual code change.

            Assignee:
            Trevor Guidry
            Reporter:
            Joseph Obaraye
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: