Skip to content

Commit

Permalink
Add pyright job (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleoold authored May 1, 2021
1 parent af683e2 commit fe1313e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 8 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: pyright

on:
push:
schedule:
- cron: 0 9 * * 4

jobs:
on-ubuntu-latest-py37:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Set up npm
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
- name: Check types with Pyright
run: |
npx pyright
14 changes: 14 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"include": ["types_linq", "tests"],
"pythonVersion": "3.7",
"typeCheckingMode":"strict",
"reportUnknownLambdaType": "none",
"reportUnknownVariableType": "none",
"reportUnknownMemberType": "none",
"reportUnnecessaryIsInstance": "none",
"reportUnnecessaryCast": "none",
"reportUnknownArgumentType": "none",
"reportUnknownParameterType": "none",
"reportInvalidStubStatement": "none",
"reportPrivateUsage": "none"
}
4 changes: 2 additions & 2 deletions tests/test_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ def test_selectmany2_overload1(self):
dinner = [(533, ['ramen', 'rice']), (16, ['pork'])]
en = Enumerable(dinner)
q = en.select_many2(
lambda tup, i: [i] + tup[1],
lambda tup, i: [i] + tup[1], # type: ignore
lambda src, c: f'{src[0]}.{c}',
)
assert q.to_list() == ['533.0', '533.ramen', '533.rice', '16.1', '16.pork']
Expand Down Expand Up @@ -1598,5 +1598,5 @@ def test_fallback(self):
en3[:7]

class OnlyHasGetItemRaises(TestElementAtMethod.OnlyHasGetItem[TSource_co]):
def __getitem__(self, _):
def __getitem__(self, _): # type: ignore[override]
raise IndexError('generic error')
4 changes: 2 additions & 2 deletions types_linq/enumerable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from typing import Any, Callable, Container, Deque, Dict, Iterable, Iterator, List, NoReturn, Optional, Reversible, Sequence, Set, Sized, TYPE_CHECKING, Tuple, Type, Generic, Union
from typing import Any, Callable, Container, Deque, Dict, Iterable, Iterator, List, NoReturn, Optional, Reversible, Sequence, Set, Sized, TYPE_CHECKING, Type, Generic, Union

if TYPE_CHECKING:
from .lookup import Lookup
Expand Down Expand Up @@ -112,7 +112,7 @@ def inner(s: slice = index):
.reverse()._every(-step)
return Enumerable(inner)

def __getitem__(self,
def __getitem__(self, # type: ignore[override]
index: Union[int, slice],
) -> Union[TSource_co, Enumerable[TSource_co]]:
return self._getitem_impl(index, fallback=False)
Expand Down
4 changes: 2 additions & 2 deletions types_linq/enumerable.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class Enumerable(Sequence[TSource_co], Generic[TSource_co]):
'''

@overload
def __init__(self, __iterable: Iterable[TSource_co]):
def __init__(self, __iterable: Iterable[TSource_co]) -> None:
'''
Wraps an iterable.
'''

@overload
def __init__(self, __iterable_factory: Callable[[], Iterable[TSource_co]]):
def __init__(self, __iterable_factory: Callable[[], Iterable[TSource_co]]) -> None:
'''
Wraps an iterable returned from the iterable factory. The factory will be called whenever
an enumerating operation is performed.
Expand Down
2 changes: 1 addition & 1 deletion types_linq/ordered_enumerable.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class key:
def __init__(self, elem):
self.elem = elem
def __lt__(self, __o: key):
return comparer(selector(self.elem), selector(__o.elem)) < 0
return comparer(selector(self.elem), selector(__o.elem)) < 0 # type: ignore
lst.sort(key=key, reverse=curr._descending)
curr = curr._parent
yield from lst
Expand Down
2 changes: 1 addition & 1 deletion types_linq/ordered_enumerable.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from typing import Callable, Generic, Iterator, Optional, overload
from typing import Callable, Generic, Optional, overload

from .enumerable import Enumerable
from .more_typing import (
Expand Down

0 comments on commit fe1313e

Please sign in to comment.