mirror of
https://github.com/badges/shields.git
synced 2025-11-28 18:04:09 +03:00
Add [PypiTypes] badge (#10774)
* 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>
This commit is contained in:
40
services/pypi/pypi-types.service.js
Normal file
40
services/pypi/pypi-types.service.js
Normal file
@@ -0,0 +1,40 @@
|
||||
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 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user