checks.py_typed.PyTypedCheck
checks.py_typed.PyTypedCheck()Check for PEP 561 py.typed marker file.
Looks at the project’s own package, as found by :class:~pycmdcheck.package_layout.PackageLayout. If it has no py.typed marker, a sample of its modules and stubs is scanned, and the marker is suggested only when most public functions are annotated.
Attributes
name :-
The check identifier (
"py_typed"). description :-
Human-readable description of this check.
rules :-
Every code the check can emit, with what the rule means.
hints :-
The same codes, each with what to do about the finding.
Examples
Run the py.typed check:
>>> from pathlib import Path
>>> check = PyTypedCheck()
>>> result = check.run(Path("."), {"enabled": True})
>>> result.name
'py_typed'Methods
| Name | Description |
|---|---|
| run | Check for py.typed marker in typed packages. |
run
checks.py_typed.PyTypedCheck.run(package_path, config)Check for py.typed marker in typed packages.
Parameters
Returns
: CheckResult-
A CheckResult with:
: CheckResult-
- OK status if
py.typedis present or the package is stub-only
- OK status if
: CheckResult-
- NOTE status if most public functions are annotated but there is no
py.typedmarker
- NOTE status if most public functions are annotated but there is no
: CheckResult-
- SKIPPED status (“not-applicable”) if no package directory is found, or the package is not clearly typed (marker not needed)
: CheckResult-
- SKIPPED status (“parse-failed”) if a sampled file could not be parsed and no public function was counted in the rest. Once a function was counted, the package is graded on the files that were read