Closed PabloRuizCuevas closed 1 year ago
We can let it as a draft till we complete it, or deploy the type hints progressively, in any case I will run the pre-commit in the next days.
Thanks Pablo, I'm trying to get mypy up and running so that we can take full advantage of the type hints, but due to impending work commitments that could take a few days. At the moment running mypy on the master branch throws up a bunch of errors such as staircase\core\ops\relational.py:135: error: "Type[Series[Any]]" has no attribute "lt"
- pandas Series of course does have a lt
attribute, but it might have to do with the way these relational, logical and arithmetic methods are added to the Series class, so I'll have to figure out how to tell mypy to ignore certain errors.
Yes, I would say to allow some mypy errors in the beginning and progressively clean them. One of the reason I raise the issue about the architecture is exactly that, it will provide lots of "undefined attribute" wanings in mypy, pycharm, intellisense etc.
In any case I will do most of the typehints, but some of them I'm not 100% sure which type is, so you would need to review them. In any case mypy strict will make easy to find the hints left.
Added mypy to pyproject.toml, it has multiple exceptions and there is still multiple errors, but little by little, I think we need to create a couple of custom types like:
ScFloat = union[Inf,NegInf,float]
feel free to check what does make the most sense.
Added mypy to pyproject.toml, it has multiple exceptions and there is still multiple errors, but little by little, I think we need to create a couple of custom types like:
ScFloat = union[Inf,NegInf,float]
feel free to check what does make the most sense.
Cool, there is a file here where we can define custom types
https://github.com/staircase-dev/staircase/blob/master/staircase/_typing.py
as a direct analog for the pandas equivalent
https://github.com/pandas-dev/pandas/blob/main/pandas/_typing.py
Hi @PabloRuizCuevas, looks like typing.Literal
was introduced in Python 3.8 which is why the pipeline is failing on 3.7. I'm guessing there is a workaround but the plan is for Staircase to support Python 3.7 until the official end of life in June 2023.
I'll also try and get you the permissions to run the pipelines without requiring approval for me.
Hi, yes I know that's why I put the "import from future" but not sure if that works with pytest or there is another way of making it work...
Hi, yes I know that's why I put the "import from future" but not sure if that works with pytest or there is another way of making it work...
Looks like this package will work until support for 3.7 is dropped
@PabloRuizCuevas You may need to let the lock file overwrite your own to get past the merge commit, then redo a new one with a poetry update
with the mypy additions you've made to the pyproject file.
I added Literal from typing_extensions , let us see if we can merge this part already.
Base: 96.04% // Head: 96.06% // Increases project coverage by +0.02%
:tada:
Coverage data is based on head (
98daa2f
) compared to base (351b521
). Patch coverage: 98.78% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
I would say is good to go, the issue failing is not a issue of this PR, but the slice function overlapping a built in function.
Awesome, thanks Pablo, I'll tell Codacy to ignore the slice
conflict.
Hey Pablo, I noticed you were developing on your master branch. Pandas suggest an alternative workflow which is nice, where you develop on a new "feature branch", push that to a remote branch on your fork, then open a pull request from that branch. It then allows you to develop separate features at once (each on a different branch), eg i) black upgrade in precommit yaml ii) mypy added to pyproject.toml iii) type hints added. You can continue to sync your fork with the original, pull down changes to your master branch, and then merge those changes to whatever work-in-progress you have on your "feature branches". You may already be aware of this but thought I'd mention it just in case. Thanks again for this contribution, it will pave the way for more type hints in the future!
Yes, I agree, no objection from my side, normally I develop in feature branches, but I wasn't thinking at the time on having different contributions at the same time. And you're welcome :) thanks for having developed this package!