diff --git a/services/pypi/pypi-types.service.js b/services/pypi/pypi-types.service.js index b0e38ab3283a0..736ffdf06c0d3 100644 --- a/services/pypi/pypi-types.service.js +++ b/services/pypi/pypi-types.service.js @@ -10,7 +10,7 @@ export default class PypiTypes extends PypiBase { get: { summary: 'PyPI - Types', description: - 'Whether the package provides type information, as indicated by the presence of the Typing :: Typed classifier in the package metadata', + 'Type information provided by the package, as indicated by the presence of the `Typing :: Typed` and `Typing :: Stubs Only` classifiers in the package metadata', parameters: pypiGeneralParams, }, }, @@ -18,12 +18,17 @@ export default class PypiTypes extends PypiBase { static defaultBadgeData = { label: 'types' } - static render({ isTyped }) { + static render({ isTyped, isStubsOnly }) { if (isTyped) { return { message: 'typed', color: 'brightgreen', } + } else if (isStubsOnly) { + return { + message: 'stubs', + color: 'brightgreen', + } } else { return { message: 'untyped', @@ -35,6 +40,9 @@ export default class PypiTypes extends PypiBase { async handle({ egg }, { pypiBaseUrl }) { const packageData = await this.fetch({ egg, pypiBaseUrl }) const isTyped = packageData.info.classifiers.includes('Typing :: Typed') - return this.constructor.render({ isTyped }) + const isStubsOnly = packageData.info.classifiers.includes( + 'Typing :: Stubs Only', + ) + return this.constructor.render({ isTyped, isStubsOnly }) } } diff --git a/services/pypi/pypi-types.tester.js b/services/pypi/pypi-types.tester.js index 369596d2d6ff1..450feea729916 100644 --- a/services/pypi/pypi-types.tester.js +++ b/services/pypi/pypi-types.tester.js @@ -9,6 +9,10 @@ t.create('types (no)') .get('/z3-solver.json') .expectBadge({ label: 'types', message: 'untyped' }) +t.create('types (stubs)') + .get('/types-requests.json') + .expectBadge({ label: 'types', message: 'stubs' }) + t.create('types (invalid)') .get('/not-a-package.json') .expectBadge({ label: 'types', message: 'package or version not found' })