Comments (5)
@Krukov There must be automated CI checks that enforce developers to use the same style and type hints. I see that you use Black, Isort, Flake8, but nothing is checked at GitHub and nothing is mandatory.
There are two options:
- I add https://github.com/pre-commit/pre-commit because I've been using it for a long time and I have a ready to copy/paste config. The only problem is that I use GitLab and I will need to learn how to update CI at GitHub.
- You will enforce Mypy, Black, Isort, Flake8 checks to make them mandatory and executed at CI automatically. This option is less work for me :)
Enabling mentioned checks will also require to apply some formatting issues (run Black), sort imports (run isort), etc.
What is your opinion? I've started now to add and fix type hints. After I will finish with type hints, I would be happy to run Mypy at CI automatically to avoid making type hints broken in the future.
from cashews.
Hi,
yep, I also not so familiar with GitHub CI that is why the project have no checks for linters/formatters like black, isort and so on.
So for me any options is good, I can enforce some rules based on my experience, but also I don't mind if you will add pre-commit.
In general, pre-commit will be a good first step.
from cashews.
Is there any reason why the cashews.backends.interface.Backend
class is not defined as an abstract base class (ABCs)?
May I use @abstractmethod
for the cashews.backends.interface.Backend
class?
I think that Mypy can not know a correct return type:
class Backend:
async def keys_match(self, pattern: str) -> AsyncIterator[str]:
...
so there is an error
cashews/backends/memory.py:73: error: Return type "AsyncIterator[str]" of "keys_match" incompatible with return type "Coroutine[Any, Any, AsyncIterator[str]]" in supertype "Backend" [override]
but the following solves type hints problems:
@abstractmethod
async def keys_match(self, pattern: str) -> AsyncIterator[str]:
...
from cashews.
I am not sure but maybe we can take a look at Protocols https://peps.python.org/pep-0544/. Can it solve the problem?
The main point that ABC add runtime checking that is not necessary for typing.
Anyway I think we can add Abstract for Backend class (ABC)
from cashews.
covered by #161
from cashews.
Related Issues (20)
- Key template doesnt work correctly with class methods HOT 2
- Get keys number
- Allow cache exceptions aka. "white exceptions" HOT 6
- Current implementation of `thunder_protection` may cause "Future exception was never retrieved" warning HOT 1
- Add More contrib modules
- Pass cache result into ttl function HOT 5
- Timeout and Cancelled errors HOT 6
- Utilizing Functions as Key Generators HOT 3
- [Migration] [User experience] An exception must be raised if `cache.setup()` was not called HOT 2
- [removed by author]
- A wrong exception is raised when `prefix` from the setup does not match a prefix in a passed `key` HOT 2
- Is the `cache-control` header set? HOT 9
- 'coroutine' object has no attribute 'execute_command' - Client Side Caching HOT 4
- Does cashews need handle `IndexError` in `handle_message` in "redis/asyncio/client.py"? HOT 3
- AttributeError: 'Redis' object has no attribute '_client' HOT 4
- "No connection available" errors with redis-py 5.0.1 HOT 3
- Middleware to add "X-From-Cache" in response header throws AttributeError HOT 1
- Unable to disable cache by providing "enable=0" or "disable=1" in cache setup HOT 4
- Improve docs HOT 1
- Templated tags with None values throw TagNotRegisteredError HOT 1
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 cashews.