-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add python typing badge * prettier * Update services/pypi/pypi-typing.service.js Co-authored-by: jNullj <[email protected]> * address comments * rename * fix test --------- Co-authored-by: jNullj <[email protected]>
- Loading branch information
1 parent
85b44b9
commit bf91e26
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createServiceTester } from '../tester.js' | ||
export const t = await createServiceTester() | ||
|
||
t.create('types (yes)') | ||
.get('/pyre-check.json') | ||
.expectBadge({ label: 'types', message: 'typed' }) | ||
|
||
t.create('types (no)') | ||
.get('/z3-solver.json') | ||
.expectBadge({ label: 'types', message: 'untyped' }) | ||
|
||
t.create('types (invalid)') | ||
.get('/not-a-package.json') | ||
.expectBadge({ label: 'types', message: 'package or version not found' }) |