mirror of
https://github.com/google/pybadges.git
synced 2025-07-21 12:41:08 +02:00
Add type validate
This commit is contained in:
@@ -23,6 +23,17 @@ jobs:
|
|||||||
sudo pip install nox
|
sudo pip install nox
|
||||||
nox -f noxfile.py -s lint
|
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:
|
Release:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python:3.7.1
|
- image: circleci/python:3.7.1
|
||||||
@@ -43,6 +54,7 @@ workflows:
|
|||||||
jobs:
|
jobs:
|
||||||
- Unit Test
|
- Unit Test
|
||||||
- Lint
|
- Lint
|
||||||
|
- Type Check
|
||||||
release:
|
release:
|
||||||
jobs:
|
jobs:
|
||||||
- Release:
|
- Release:
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,6 +47,7 @@ coverage.xml
|
|||||||
*.cover
|
*.cover
|
||||||
.hypothesis/
|
.hypothesis/
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
|
.pytype
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
*.mo
|
*.mo
|
||||||
|
11
noxfile.py
11
noxfile.py
@@ -44,3 +44,14 @@ def unit(session, pip_installs):
|
|||||||
'tests',
|
'tests',
|
||||||
*session.posargs
|
*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 io
|
||||||
import json
|
import json
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from typing import Mapping, TextIO, Type
|
from typing import cast, Mapping, TextIO, Type
|
||||||
|
|
||||||
from pybadges import text_measurer
|
from pybadges import text_measurer
|
||||||
|
|
||||||
@@ -80,7 +80,8 @@ class PrecalculatedTextMeasurer(text_measurer.TextMeasurer):
|
|||||||
with pkg_resources.resource_stream(__name__,
|
with pkg_resources.resource_stream(__name__,
|
||||||
'default-widths.json.xz') as f:
|
'default-widths.json.xz') as f:
|
||||||
with lzma.open(f, "rt") as g:
|
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
|
return cls._default_cache
|
||||||
elif pkg_resources.resource_exists(__name__, 'default-widths.json'):
|
elif pkg_resources.resource_exists(__name__, 'default-widths.json'):
|
||||||
with pkg_resources.resource_stream(__name__,
|
with pkg_resources.resource_stream(__name__,
|
||||||
|
Reference in New Issue
Block a user