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

package_path : Path

Path to the package directory to check.

config : dict[str, Any]

Configuration dictionary for this check. Currently no check-specific options are used.

Returns

: CheckResult

A CheckResult with:

: CheckResult
  • OK status if py.typed is present or the package is stub-only
: CheckResult
  • NOTE status if most public functions are annotated but there is no py.typed marker
: 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