pygradle icon indicating copy to clipboard operation
pygradle copied to clipboard

Support for mypy

Open warsaw opened this issue 7 years ago • 0 comments

I have a Python 3 project which uses type annotations. I wanted to be able to run mypy over my code as a standard code quality check. @ethankhall and @zvezdan helped me add some code to my build.gradle file to make this happen, and I've been happy with it so far. I'm not sure of the best way to integrated this into pygradle by default, so for now I'll open this ticket and include the code inline.

class MyPy extends com.linkedin.gradle.python.tasks.AbstractPythonMainSourceDefaultTask {
    void preExecution() {
        args(pythonDetails.virtualEnvironment.findExecutable('mypy').absolutePath)
        args('--ignore-missing-imports', 'src')
    }
    void processResults(org.gradle.process.ExecResult results) {
    }
}

// We want the check task to always run mypy too.
task mypy(type: MyPy)
check.dependsOn(mypy)

warsaw avatar Jan 18 '18 19:01 warsaw