Comments (3)
I didn't know about py.typed
either, that's news to me :)
In any case, good idea. I'll add it to this library (and possibly a few others as well).
Due to the fragile nature of apple hardware my laptop is currently out of commission unfortunately, and that's the only system I've completely setup to properly create new releases with signing and everything so it'll probably take a few weeks until I can create a new release.
from portalocker.
Thank you for adding this! Now I can have this in some commits!
-import portalocker # type: ignore[import]
+import portalocker
There is one tinsy little issue I ran into when using the type hint -- the exception base class is not type hinted. I think the following is sufficient to type hint it:
+import typing
+
+
class BaseLockException(Exception):
# Error codes:
LOCK_FAILED = 1
- def __init__(self, *args, fh=None, **kwargs):
+ def __init__(
+ self,
+ *args: typing.Any,
+ fh: typing.Optional[typing.IO] = None,
+ **kwargs: typing.Any,
+ ) -> None:
self.fh = fh
Exception.__init__(self, *args, **kwargs)
That was the only one I ran into directly. Checking the package shows a few untyped functions. These are in utils
though, so I am guessing these probably do not matter much for the users.
portalocker.utils.coalesce(*args: typing.Any, test_value: typing.Any = None)
https://github.com/WoLpH/portalocker/blob/631352fbfd9f2b780a6d5f9da39646f4088910aa/portalocker/utils.py#L31portalocker.utils.LockBase._timeout_generator(self, timeout: float, check_interval: float)
https://github.com/WoLpH/portalocker/blob/631352fbfd9f2b780a6d5f9da39646f4088910aa/portalocker/utils.py#L132portalocker.utils.LockBase.__exit__(self, type_, value, tb)
: This one is a little more complicated, and requires extra imports, as suggested in https://mypy.readthedocs.io/en/stable/protocols.html#contextmanager-t
https://github.com/WoLpH/portalocker/blob/631352fbfd9f2b780a6d5f9da39646f4088910aa/portalocker/utils.py#L155- I have not used
__delete__
before.
https://github.com/WoLpH/portalocker/blob/631352fbfd9f2b780a6d5f9da39646f4088910aa/portalocker/utils.py#L158 portalocker.utils.BoundedSemaphore.get_filename(self, number: int)
https://github.com/WoLpH/portalocker/blob/631352fbfd9f2b780a6d5f9da39646f4088910aa/portalocker/utils.py#L389
There are also two in the redis
module, but I do not know enough about it to suggest anything, and the redis-py
package does not seem to have type hints anyway.
- https://github.com/WoLpH/portalocker/blob/631352fbfd9f2b780a6d5f9da39646f4088910aa/portalocker/redis.py#L113
- https://github.com/WoLpH/portalocker/blob/631352fbfd9f2b780a6d5f9da39646f4088910aa/portalocker/redis.py#L179
from portalocker.
I completely forgot to reply to this... obviously we've already had a few releases so it's definitely included but it's certainly not perfect yet. I've improved the type hints somewhat but I'm not at 100% coverage yet
Perhaps some day :)
Thank you for all the help @BoniLindsley!
from portalocker.
Related Issues (20)
- race condition for⦠file metadata? HOT 4
- Setting the DenyMode against a file HOT 2
- is lock reenterable? HOT 2
- distutils was depreacted in Python 3.10 HOT 2
- Timeout not working with SHARED flag HOT 4
- Better Examples Needed HOT 3
- LockException(OSError(22, 'Invalid argument')) when using NON_BLOCKING flag on Linux HOT 2
- DLL load failed while importing win32file HOT 1
- What is the actual license for this project? HOT 1
- fileno support HOT 2
- Mismatch between documentation and implementation HOT 3
- How to lock a file but be able to read it HOT 4
- Python 3.12: ModuleNotFoundError: No module named 'distutils' HOT 2
- Require explicit name for BoundedSemaphore()? HOT 9
- docs files are installed in the wrong location HOT 5
- Version 2.7.0 Released in January 2023 was updated recently to remove support for Python 3.7 HOT 13
- 'portalocker' has no attribute 'LockFlags'
- lock on NFS mount not working HOT 10
- Is this 2016 StackOverflow answer still accurate? (`fh = open(p); Lock(fh)` vs. `with Lock(p) as fh`) HOT 2
- Type hints for utils.Lock.acquire (and __enter__) incorrect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from portalocker.