Skip to content

Commit

Permalink
TYP: switch to GHA for mypy instead of pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Jan 29, 2022
1 parent 73c1668 commit 2984158
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 16 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/type-checking.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: type checking

on:
push:
branches:
- main
pull_request:
paths-ignore:
- README.md

jobs:
build:
runs-on: ubuntu-latest
name: mypy
timeout-minutes: 10

concurrency:
group: ${{ github.ref }}-dev
cancel-in-progress: true

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Build yt + type check deps
run: |
python3 -m pip install --upgrade pip
python3 -m pip install .[typecheck]
- name: Run mypy
run: mypy inifix
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,3 @@ repos:
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
hooks:
- id: mypy
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.0.1] - 2022-01-30

TYP: improve type-correctness [PR #93](https://github.com/neutrinoceros/inifix/pull/93)

## [1.0.0] - 2022-01-15

The API is now declared stable and any future intentionally breaking change
Expand All @@ -16,7 +20,7 @@ will follow a deprecation cycle.
- TYP: add mypy conf, add missing type annotations


https://github.com/neutrinoceros/inifix/pull/91
[PR #91](https://github.com/neutrinoceros/inifix/pull/91)

## [0.11.2] - 2022-01-05

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `inifix`

[![PyPI](https://img.shields.io/pypi/v/inifix.svg?logo=pypi&logoColor=white&label=PyPI)](https://pypi.org/project/inifix/)
[![PyPI](https://img.shields.io/pypi/pyversions/inifix/1.0.0?logo=python&logoColor=white&label=Python)](https://pypi.org/project/inifix/)
[![PyPI](https://img.shields.io/pypi/pyversions/inifix/1.0.1?logo=python&logoColor=white&label=Python)](https://pypi.org/project/inifix/)
[![codecov](https://codecov.io/gh/neutrinoceros/inifix/branch/main/graph/badge.svg)](https://codecov.io/gh/neutrinoceros/inifix)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/neutrinoceros/inifix/main.svg)](https://results.pre-commit.ci/badge/github/neutrinoceros/inifix/main.svg)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
Expand Down
2 changes: 1 addition & 1 deletion inifix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .io import load
from .validation import validate_inifile_schema

__version__ = "1.0.0"
__version__ = "1.0.1"
11 changes: 5 additions & 6 deletions inifix/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
from typing import AnyStr
from typing import Dict
from typing import Iterable
from typing import Optional
from typing import TypeVar
from typing import Union

T = TypeVar("T")
Scalar = Union[int, float, bool, str]
IterableOrSingle = Union[Iterable[T], T]

if sys.version_info >= (3, 9):
PathLike = Union[AnyStr, os.PathLike[AnyStr]]
else:
PathLike = Union[AnyStr, os.PathLike]

T = TypeVar("T")
Scalar = Union[int, float, bool, str]
IterableOrSingle = Union[Iterable[T], T]

# these types are used to validate schemas internally at type-checking time
SectionT = Dict[str, IterableOrSingle[Scalar]]
InifixConfT = Dict[Optional[str], SectionT]
InifixConfT = Union[Dict[str, SectionT], SectionT]
4 changes: 3 additions & 1 deletion inifix/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def _tokenize_line(

def _from_file_descriptor(file: TextIO) -> InifixConfT:
data = file.read()
container: InifixConfT = {}

# see https://github.com/python/mypy/issues/6463
container: InifixConfT = {} # type: ignore[assignment]
lines = _normalize_data(data)
if not "".join(lines):
raise ValueError(f"{file.name!r} appears to be empty.")
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = inifix
version = 1.0.0
version = 1.0.1
description = I/O facility for Idefix/Pluto configuration files
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -37,6 +37,8 @@ console_scripts =
dev =
pre-commit
pytest>=6.1
typecheck =
mypy==0.931

[flake8]
exclude = *__init__.py
Expand Down

0 comments on commit 2984158

Please sign in to comment.