-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix reading resource when packaged in zip #170
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #170 +/- ##
==========================================
- Coverage 92.85% 91.40% -1.46%
==========================================
Files 3 3
Lines 126 128 +2
==========================================
Hits 117 117
- Misses 9 11 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
src/em/__init__.py
Outdated
@@ -15,6 +15,6 @@ | |||
|
|||
from __future__ import annotations | |||
|
|||
from em import _version | |||
from em import _version # type: ignore[attr-defined] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed? It passes for me without it:
from em import _version # type: ignore[attr-defined] | |
from em import _version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a mypy failure in CI without it.
The _version.py
file is created dynamically by hatch-vcs
. It doesn't exist until the package is built, so before that mypy will fail (without the type: ignore
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah of course. That reminds me, mypy generally works better on a whole installed project rather than file-by-file via pre-commit, so let's move it to tox.
I realise the following is a bit of scope creep, so I'm also fine leaving it out of pre-commit for now and we can do the tox stuff later.
Please could you add it like here:
https://github.com/hugovk/tinytext/blob/a3300952a281f43480c0b914756c687c956dbc41/tox.ini#L41-L45
And add:
https://github.com/hugovk/tinytext/blob/main/requirements-mypy.txt
And whatever relevant config. We can omit strict
for now and add the exclude
here:
Then run on GitHub Actions:
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clear instructions. The scope creep was my fault, haha, so thought I'd have it fixed here and now.
.pre-commit-config.yaml
Outdated
rev: v1.14.1 | ||
hooks: | ||
- id: mypy | ||
files: '^src/em/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's include tests/
too, perhaps by removing files:
and excluding scripts/
?
Thank you! |
Fixes #169
I was unsure of the
Traversable
type's API, so I checked types with mypy, and made small changes to make it pass. Those changes are also included, but I can remove or separate those changes if that's better.