mirror of
https://github.com/google/pybadges.git
synced 2025-07-21 04:31:07 +02:00
Add type validate
This commit is contained in:
@@ -23,6 +23,17 @@ jobs:
|
||||
sudo pip install nox
|
||||
nox -f noxfile.py -s lint
|
||||
|
||||
Type Check:
|
||||
- image: circleci/python:3.7.1
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
command: |
|
||||
sudo pip install virtualenv
|
||||
sudo pip install nox
|
||||
nox -f noxfile.py -s type_check
|
||||
|
||||
Release:
|
||||
docker:
|
||||
- image: circleci/python:3.7.1
|
||||
@@ -43,6 +54,7 @@ workflows:
|
||||
jobs:
|
||||
- Unit Test
|
||||
- Lint
|
||||
- Type Check
|
||||
release:
|
||||
jobs:
|
||||
- Release:
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,6 +47,7 @@ coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
.pytype
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
11
noxfile.py
11
noxfile.py
@@ -44,3 +44,14 @@ def unit(session, pip_installs):
|
||||
'tests',
|
||||
*session.posargs
|
||||
)
|
||||
|
||||
@nox.session
|
||||
def type_check(session):
|
||||
"""Run type checking using pytype."""
|
||||
session.install('-e', '.[dev]')
|
||||
session.install('pytype')
|
||||
session.run(
|
||||
'pytype',
|
||||
'--python-version=3.6',
|
||||
'--disable=pyi-error',
|
||||
'pybadges')
|
||||
|
@@ -20,7 +20,7 @@ Uses a precalculated set of metrics to calculate the string length.
|
||||
import io
|
||||
import json
|
||||
import pkg_resources
|
||||
from typing import Mapping, TextIO, Type
|
||||
from typing import cast, Mapping, TextIO, Type
|
||||
|
||||
from pybadges import text_measurer
|
||||
|
||||
@@ -80,7 +80,8 @@ class PrecalculatedTextMeasurer(text_measurer.TextMeasurer):
|
||||
with pkg_resources.resource_stream(__name__,
|
||||
'default-widths.json.xz') as f:
|
||||
with lzma.open(f, "rt") as g:
|
||||
cls._default_cache = PrecalculatedTextMeasurer.from_json(g)
|
||||
cls._default_cache = PrecalculatedTextMeasurer.from_json(
|
||||
cast(TextIO, g))
|
||||
return cls._default_cache
|
||||
elif pkg_resources.resource_exists(__name__, 'default-widths.json'):
|
||||
with pkg_resources.resource_stream(__name__,
|
||||
|
Reference in New Issue
Block a user