mirror of
https://github.com/badges/shields.git
synced 2025-11-28 18:04:09 +03:00
* add python typing badge * prettier * Update services/pypi/pypi-typing.service.js Co-authored-by: jNullj <15849761+jNullj@users.noreply.github.com> * address comments * rename * fix test --------- Co-authored-by: jNullj <15849761+jNullj@users.noreply.github.com>
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
import PypiBase, { pypiGeneralParams } from './pypi-base.js'
|
|
|
|
export default class PypiTypes extends PypiBase {
|
|
static category = 'platform-support'
|
|
|
|
static route = this.buildRoute('pypi/types')
|
|
|
|
static openApi = {
|
|
'/pypi/types/{packageName}': {
|
|
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',
|
|
parameters: pypiGeneralParams,
|
|
},
|
|
},
|
|
}
|
|
|
|
static defaultBadgeData = { label: 'types' }
|
|
|
|
static render({ isTyped }) {
|
|
if (isTyped) {
|
|
return {
|
|
message: 'typed',
|
|
color: 'brightgreen',
|
|
}
|
|
} else {
|
|
return {
|
|
message: 'untyped',
|
|
color: 'red',
|
|
}
|
|
}
|
|
}
|
|
|
|
async handle({ egg }, { pypiBaseUrl }) {
|
|
const packageData = await this.fetch({ egg, pypiBaseUrl })
|
|
const isTyped = packageData.info.classifiers.includes('Typing :: Typed')
|
|
return this.constructor.render({ isTyped })
|
|
}
|
|
}
|