Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add pyright type checker during CI #24

Merged
merged 6 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ jobs:
run: |
flake8 .

- uses: jordemort/action-pyright@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-check
lib:
level: warning
filter_mode: file

- name: Test Pytest
run: |
pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Expand Down
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"recommendations": [
"ms-python.flake8",
"github.vscode-github-actions",
"ms-python.vscode-pylance",
"ms-python.python",
"ms-python.debugpy",
"ms-python.black-formatter"
]
}
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"editor.fontSize": 16,
"python.formatting.provider": "none",
"python.linting.flake8Enabled": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
}
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,11 @@ python_files = "Test*.py"
testpaths = [
"tests"
]
addopts = "--doctest-modules --junitxml=junit/test-results.xml --cov=src --cov-report=xml --cov-report=html"
addopts = "--doctest-modules --junitxml=junit/test-results.xml --cov=src --cov-report=xml --cov-report=html"

[tool.pyright]
include = ["src"]
exclude = [
"**/node_modules",
"**/__pycache__"
]
2 changes: 1 addition & 1 deletion src/Artesian/Exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ArtesianSdkOptimisticConcurrencyException(ArtesianSdkRemoteException):
"""

def __init__(
self: ArtesianSdkValidationException,
self: ArtesianSdkOptimisticConcurrencyException,
method: str,
url: str,
statusCode: int,
Expand Down
19 changes: 8 additions & 11 deletions src/Artesian/GMEPublicOffers/GMEPublicOfferQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,19 @@ def __getMarket(self: GMEPublicOfferQuery, market: Market) -> str:
raise Exception("Not supported Market")
return vr

def __getPurpose(self: GMEPublicOfferQuery, purpose: Purpose) -> str:
def __getPurpose(self: GMEPublicOfferQuery, purpose: Purpose | None) -> str:
if purpose is None:
raise Exception("Not supported Purpose")
switcher = {Purpose.BID: "BID", Purpose.OFF: "OFF"}
vr = switcher.get(purpose, "Defpurp")
if vr == "Defpurp":
raise Exception("Not supported Purpose")
return vr

def __getStatus(self: GMEPublicOfferQuery, status: Status) -> str:
def __getStatus(self: GMEPublicOfferQuery, status: Status | None) -> str:
if status is None:
raise Exception("Not supported Status")

switcher = {
Status.ACC: "ACC",
Status.INC: "INC",
Expand Down Expand Up @@ -429,14 +434,6 @@ def _buildExtractionRangeRoute(
subPath = f"{self.__toUrlParam(queryParamaters.extractionRangeConfig.date)}"
return subPath

def _buildExtractionStatus(self: GMEPublicOfferQuery, status: Status) -> str:
subPath = f"{parse.quote_plus(status)}"
return subPath

def _buildExtractionPurpose(self: GMEPublicOfferQuery, purpose: Purpose) -> str:
subPath = f"{parse.quote_plus(purpose)}"
return subPath

def _exec(self: GMEPublicOfferQuery, url: str) -> Any:
loop = get_event_loop()
rr = loop.run_until_complete(self._execAsync(url))
Expand All @@ -449,7 +446,7 @@ async def _execAsync(self: GMEPublicOfferQuery, url: str) -> Any:
)
return res[0]

def __toUrlParam(self: GMEPublicOfferQuery, date: str) -> str:
def __toUrlParam(self: GMEPublicOfferQuery, date: str | None) -> str:
return f"{date}"

def _validateQuery(self: GMEPublicOfferQuery) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/Artesian/MarketData/MarketDataService.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def searchFacetAsync(
self: MarketDataService,
page: int,
pageSize: int,
searchText: str = None,
searchText: str | None = None,
filters: Optional[Dict[str, List[str]]] = None,
sorts: Optional[List[str]] = None,
doNotLoadAdditionalInfo: bool = False,
Expand Down
2 changes: 1 addition & 1 deletion src/Artesian/MarketData/_Dto/ArtesianMetadataFacet.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class ArtesianMetadataFacet:
"""

facetName: Optional[str] = None
facetType: ArtesianMetadataFacetType = None
facetType: Optional[ArtesianMetadataFacetType] = None
values: Optional[List[ArtesianMetadataFacetCount]] = None
13 changes: 9 additions & 4 deletions src/Artesian/Query/DefaultPartitionStrategy.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from __future__ import annotations
import copy
from typing import List
from typing import List, TypeVar

from ._QueryParameters.QueryParameters import _QueryParameters
from ._QueryParameters.ActualQueryParameters import ActualQueryParameters
from ._QueryParameters.VersionedQueryParameters import VersionedQueryParameters
from ._QueryParameters.AuctionQueryParameters import AuctionQueryParameters
from ._QueryParameters.MasQueryParameters import MasQueryParameters
from ._QueryParameters.BidAskQueryParameters import BidAskQueryParameters


T = TypeVar("T", bound=_QueryParameters)


class DefaultPartitionStrategy:
"""Class for the default strategy to partition Query Parameters."""

Expand Down Expand Up @@ -89,9 +94,9 @@ def PartitionBidAsk(
return self._tsPartitionStrategy(bidAskQueryParameters)

def _tsPartitionStrategy(
self: DefaultPartitionStrategy, Parameters: List[MasQueryParameters]
) -> List[MasQueryParameters]:
res: List[MasQueryParameters] = []
self: DefaultPartitionStrategy, Parameters: List[T]
) -> List[T]:
res: List[T] = []
for param in Parameters:
if param.ids is None:
res.append(param)
Expand Down
2 changes: 1 addition & 1 deletion src/Artesian/Query/_Query.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async def _execAsync(self: _Query, urls: List[str]) -> list:
)
return list(itertools.chain(*res))

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

def _validateQuery(self: _Query) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/Artesian/Query/_QueryParameters/QueryParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def getUrlParams(self: _FillCustomTimeserieStrategy) -> str:
return f"fillerK=CustomValue&fillerDV={self.val}"


def toQueryParams(vals: List[List[str]]) -> str:
def toQueryParams(vals: List[List[str | float | int | None]]) -> str:
filtered = filter(lambda x: x[1], vals)
stringVals = map(lambda x: [x[0], str(x[1])], filtered)
joinedEqual = map(lambda x: "=".join(x), stringVals)
Expand Down
2 changes: 1 addition & 1 deletion src/Artesian/_ClientsExecutor/ArtesianJsonSerializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __artesianDictDeserializer(
obj: list, cls: type, *args: Any, **kwargs: Any
) -> object:
key, value = get_args(cls)
result: Dict[key, value] = {
result: Dict[key, value] = { # type: ignore
jsons.load(item["Key"], key, *args, **kwargs): jsons.load(
item["Value"], value, *args, **kwargs
)
Expand Down
Loading