Repository navigation
Strict typing - #103
Strict typing#103
Conversation
|
|
||
| @overload | ||
| def __get__(self, inst: _TSelf[_T], owner: Optional[type[object]] = None) -> _T: ... | ||
| def __get__(self, inst: _CacheImpl, owner: Optional[type[object]] = None) -> _T: ... |
Check notice
Code scanning / CodeQL
Statement has no effect
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI over 1 year ago
To fix the problem, we need to remove the ellipsis (...) on line 41 and ensure that the method signature is correctly defined. The ellipsis is likely a placeholder that was mistakenly left in the code. We should replace it with the appropriate method signature that matches the intended functionality.
- Remove the ellipsis (
...) on line 41. - Ensure that the method signature for the
__get__method is correctly defined.
| @@ -40,3 +40,3 @@ | ||
| @overload | ||
| def __get__(self, inst: _CacheImpl, owner: Optional[type[object]] = None) -> _T: ... | ||
| def __get__(self, inst: _CacheImpl, owner: Optional[type[object]] = None) -> _T: | ||
|
|
CodSpeed Performance ReportMerging #103 will not alter performanceComparing Summary
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #103 +/- ##
==========================================
+ Coverage 88.99% 97.66% +8.66%
==========================================
Files 18 18
Lines 745 770 +25
Branches 75 40 -35
==========================================
+ Hits 663 752 +89
+ Misses 64 10 -54
+ Partials 18 8 -10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| class APIProtocol(Protocol): | ||
| def cached_property( | ||
| self, func: Callable[[Any], _T_co] | ||
| ) -> cached_property[_T_co]: ... |
Check notice
Code scanning / CodeQL
Statement has no effect
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI over 1 year ago
To fix the problem, we should replace the ellipsis with a pass statement. This will make it clear that the method is intentionally left without an implementation, which is a common practice in abstract base classes or protocols. The pass statement is a no-op (no operation) statement in Python, which means it does nothing but is syntactically valid.
| @@ -18,3 +18,3 @@ | ||
| self, func: Callable[[Any], _T_co] | ||
| ) -> cached_property[_T_co]: ... | ||
| ) -> cached_property[_T_co]: pass | ||
|
|
| class APIProtocol(Protocol): | ||
| def under_cached_property( | ||
| self, func: Callable[[Any], _T_co] | ||
| ) -> under_cached_property[_T_co]: ... |
Check notice
Code scanning / CodeQL
Statement has no effect
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI over 1 year ago
To fix the problem, we need to replace the ellipsis with a proper implementation or an abstract method declaration. Since this is a protocol, the method should be marked as abstract to indicate that it must be implemented by any subclass. We can use the abc module to achieve this.
- Replace the ellipsis with
passto indicate that the method has no implementation in the protocol itself. - Import
ABCandabstractmethodfrom theabcmodule. - Modify the
APIProtocolclass to inherit fromABCand mark theunder_cached_propertymethod as abstract.
| @@ -13,7 +13,9 @@ | ||
|
|
||
| from abc import ABC, abstractmethod | ||
|
|
||
| class APIProtocol(Protocol): | ||
| class APIProtocol(ABC, Protocol): | ||
| @abstractmethod | ||
| def under_cached_property( | ||
| self, func: Callable[[Any], _T_co] | ||
| ) -> under_cached_property[_T_co]: ... | ||
| ) -> under_cached_property[_T_co]: pass | ||
|
|
Fixes #53. Probably fixes #81.