Skip to content

Commit

Permalink
Add basic support for --verifytypes; closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Mar 16, 2022
1 parent 22ae365 commit 26b3503
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ inputs:
description: 'Use library code to infer types when stubs are missing.'
required: false
default: 'false'
verify-types:
description: 'Package name to run the type verifier on; must be an *installed* library. Any score under 100% will fail the build.'
required: false
extra-args:
description: 'Extra arguments; can be used to specify specific files to check.'
required: false
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ inputs:
description: 'Use exit code of 1 if warnings are reported.'
required: false
default: 'false'
verify-types:
description: description: 'Package name to run the type verifier on; must be an *installed* library. Any score under 100% will fail the build.'
required: false
extra-args:
description: 'Extra arguments; can be used to specify specific files to check.'
required: false
Expand Down
7 changes: 6 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6198,7 +6198,7 @@ async function main() {
console.log(`pyright ${version}, node ${process.version}`);
const { args, noComments } = await getArgs(version);
console.log(`${process.execPath} ${args.join(" ")}`);
if (noComments) {
if (noComments || args.indexOf("--verifytypes") >= 0) {
const { status: status2 } = cp.spawnSync(process.execPath, args, {
stdio: ["ignore", "inherit", "inherit"]
});
Expand Down Expand Up @@ -6291,6 +6291,11 @@ async function getArgs(version) {
if (warnings) {
args.push("--warnings");
}
const verifyTypes = core.getInput("verify-types");
if (project) {
args.push("--verifytypes");
args.push(verifyTypes);
}
const extraArgs = core.getInput("extra-args");
if (extraArgs) {
args.push(...(0, import_string_argv.default)(extraArgs));
Expand Down
15 changes: 13 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ export async function main() {
const { args, noComments } = await getArgs(version);
console.log(`${process.execPath} ${args.join(' ')}`);

if (noComments) {
// Comments are disabled, just run as a subprocess passing things through.
if (noComments || args.indexOf('--verifytypes') >= 0) {
// If comments are disabled, there's no point in directly processing the output,
// as it's only used for comments.
// If we're running the type verifier, there's no guarantee that we can even act
// on the output besides the exit code.
//
// So, in either case, just directly run pyright and exit with its status.
const { status } = cp.spawnSync(process.execPath, args, {
stdio: ['ignore', 'inherit', 'inherit'],
});
Expand Down Expand Up @@ -150,6 +155,12 @@ async function getArgs(version: SemVer) {
args.push('--warnings');
}

const verifyTypes = core.getInput('verify-types');
if (project) {

This comment has been minimized.

Copy link
@JelleZijlstra

JelleZijlstra Mar 16, 2022

Should this be if (verifyTypes)?

This comment has been minimized.

Copy link
@jakebailey

jakebailey Mar 16, 2022

Author Owner

Ugh, sure should. That's what I get for copy pasting.

args.push('--verifytypes');
args.push(verifyTypes);
}

const extraArgs = core.getInput('extra-args');
if (extraArgs) {
args.push(...stringArgv(extraArgs));
Expand Down

0 comments on commit 26b3503

Please sign in to comment.