Skip to content

Commit 495dc6c

Browse files
authored
Merge pull request #24 from ARKlab/feature/add_pyright_checker
ci: add pyright type checker during CI
2 parents 7de7962 + c69dcd3 commit 495dc6c

File tree

12 files changed

+50
-25
lines changed

12 files changed

+50
-25
lines changed

.github/workflows/python-tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ jobs:
3636
run: |
3737
flake8 .
3838
39+
- uses: jordemort/action-pyright@v1
40+
with:
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
reporter: github-check
43+
lib:
44+
level: warning
45+
filter_mode: file
46+
3947
- name: Test Pytest
4048
run: |
4149
pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"recommendations": [
3+
"ms-python.flake8",
4+
"github.vscode-github-actions",
5+
"ms-python.vscode-pylance",
6+
"ms-python.python",
7+
"ms-python.debugpy",
8+
"ms-python.black-formatter"
9+
]
10+
}

.vscode/settings.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
"python.testing.pytestEnabled": true,
33
"python.testing.unittestEnabled": false,
44
"editor.fontSize": 16,
5-
"python.formatting.provider": "none",
6-
"python.linting.flake8Enabled": true,
75
"editor.formatOnPaste": true,
86
"editor.formatOnSave": true,
97
"[python]": {
108
"editor.defaultFormatter": "ms-python.black-formatter"
119
}
12-
}
10+
}

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,11 @@ python_files = "Test*.py"
155155
testpaths = [
156156
"tests"
157157
]
158-
addopts = "--doctest-modules --junitxml=junit/test-results.xml --cov=src --cov-report=xml --cov-report=html"
158+
addopts = "--doctest-modules --junitxml=junit/test-results.xml --cov=src --cov-report=xml --cov-report=html"
159+
160+
[tool.pyright]
161+
include = ["src"]
162+
exclude = [
163+
"**/node_modules",
164+
"**/__pycache__"
165+
]

src/Artesian/Exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ArtesianSdkOptimisticConcurrencyException(ArtesianSdkRemoteException):
125125
"""
126126

127127
def __init__(
128-
self: ArtesianSdkValidationException,
128+
self: ArtesianSdkOptimisticConcurrencyException,
129129
method: str,
130130
url: str,
131131
statusCode: int,

src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,19 @@ def __getMarket(self: GMEPublicOfferQuery, market: Market) -> str:
348348
raise Exception("Not supported Market")
349349
return vr
350350

351-
def __getPurpose(self: GMEPublicOfferQuery, purpose: Purpose) -> str:
351+
def __getPurpose(self: GMEPublicOfferQuery, purpose: Purpose | None) -> str:
352+
if purpose is None:
353+
raise Exception("Not supported Purpose")
352354
switcher = {Purpose.BID: "BID", Purpose.OFF: "OFF"}
353355
vr = switcher.get(purpose, "Defpurp")
354356
if vr == "Defpurp":
355357
raise Exception("Not supported Purpose")
356358
return vr
357359

358-
def __getStatus(self: GMEPublicOfferQuery, status: Status) -> str:
360+
def __getStatus(self: GMEPublicOfferQuery, status: Status | None) -> str:
361+
if status is None:
362+
raise Exception("Not supported Status")
363+
359364
switcher = {
360365
Status.ACC: "ACC",
361366
Status.INC: "INC",
@@ -429,14 +434,6 @@ def _buildExtractionRangeRoute(
429434
subPath = f"{self.__toUrlParam(queryParamaters.extractionRangeConfig.date)}"
430435
return subPath
431436

432-
def _buildExtractionStatus(self: GMEPublicOfferQuery, status: Status) -> str:
433-
subPath = f"{parse.quote_plus(status)}"
434-
return subPath
435-
436-
def _buildExtractionPurpose(self: GMEPublicOfferQuery, purpose: Purpose) -> str:
437-
subPath = f"{parse.quote_plus(purpose)}"
438-
return subPath
439-
440437
def _exec(self: GMEPublicOfferQuery, url: str) -> Any:
441438
loop = get_event_loop()
442439
rr = loop.run_until_complete(self._execAsync(url))
@@ -449,7 +446,7 @@ async def _execAsync(self: GMEPublicOfferQuery, url: str) -> Any:
449446
)
450447
return res[0]
451448

452-
def __toUrlParam(self: GMEPublicOfferQuery, date: str) -> str:
449+
def __toUrlParam(self: GMEPublicOfferQuery, date: str | None) -> str:
453450
return f"{date}"
454451

455452
def _validateQuery(self: GMEPublicOfferQuery) -> None:

src/Artesian/MarketData/MarketDataService.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async def searchFacetAsync(
118118
self: MarketDataService,
119119
page: int,
120120
pageSize: int,
121-
searchText: str = None,
121+
searchText: str | None = None,
122122
filters: Optional[Dict[str, List[str]]] = None,
123123
sorts: Optional[List[str]] = None,
124124
doNotLoadAdditionalInfo: bool = False,

src/Artesian/MarketData/_Dto/ArtesianMetadataFacet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ class ArtesianMetadataFacet:
2929
"""
3030

3131
facetName: Optional[str] = None
32-
facetType: ArtesianMetadataFacetType = None
32+
facetType: Optional[ArtesianMetadataFacetType] = None
3333
values: Optional[List[ArtesianMetadataFacetCount]] = None

src/Artesian/Query/DefaultPartitionStrategy.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
from __future__ import annotations
22
import copy
3-
from typing import List
3+
from typing import List, TypeVar
4+
5+
from ._QueryParameters.QueryParameters import _QueryParameters
46
from ._QueryParameters.ActualQueryParameters import ActualQueryParameters
57
from ._QueryParameters.VersionedQueryParameters import VersionedQueryParameters
68
from ._QueryParameters.AuctionQueryParameters import AuctionQueryParameters
79
from ._QueryParameters.MasQueryParameters import MasQueryParameters
810
from ._QueryParameters.BidAskQueryParameters import BidAskQueryParameters
911

1012

13+
T = TypeVar("T", bound=_QueryParameters)
14+
15+
1116
class DefaultPartitionStrategy:
1217
"""Class for the default strategy to partition Query Parameters."""
1318

@@ -89,9 +94,9 @@ def PartitionBidAsk(
8994
return self._tsPartitionStrategy(bidAskQueryParameters)
9095

9196
def _tsPartitionStrategy(
92-
self: DefaultPartitionStrategy, Parameters: List[MasQueryParameters]
93-
) -> List[MasQueryParameters]:
94-
res: List[MasQueryParameters] = []
97+
self: DefaultPartitionStrategy, Parameters: List[T]
98+
) -> List[T]:
99+
res: List[T] = []
95100
for param in Parameters:
96101
if param.ids is None:
97102
res.append(param)

src/Artesian/Query/_Query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ async def _execAsync(self: _Query, urls: List[str]) -> list:
172172
)
173173
return list(itertools.chain(*res))
174174

175-
def __toUrlParam(self: _Query, start: str, end: str) -> str:
175+
def __toUrlParam(self: _Query, start: str | None, end: str | None) -> str:
176176
return f"{start}/{end}"
177177

178178
def _validateQuery(self: _Query) -> None:

0 commit comments

Comments
 (0)