Comments (10)
It looks like the failure is around properly adding the __module__
attribute to callable2
. How is that created?
from overrides.
Tracked in https://foss.heptapod.net/pypy/pypy/-/issues/4029
from overrides.
It seems to be int.bit_length.__module__
, which does not exist in cpython, but is None
in pypy. I suppose it's the usual problem with method_descriptor
on CPython, which would mean this affects the methods of all builtin types. Method descriptors don't exist in pypy, instead we have regular function objects, but with __module__
set to None
.
from overrides.
right, overrides
would produce a similar exception on CPython if you make a slightly weird method where you del
the __module__
attribute, like this:
class ASuper:
def some_method(self):
return 1
del some_method.__module__
class ASub(ASuper):
@override
def some_method(self):
return 2
yields:
tests/test_overrides.py:97: in <module>
class ASub(ASuper):
tests/test_overrides.py:98: in ASub
@override
overrides/overrides.py:143: in override
return _overrides(method, check_signature, check_at_runtime)
overrides/overrides.py:170: in _overrides
_validate_method(method, super_class, check_signature)
overrides/overrides.py:189: in _validate_method
ensure_signature_is_compatible(super_method, method, is_static)
overrides/signature.py:99: in ensure_signature_is_compatible
same_main_module = _is_same_module(sub_callable, super_callable)
overrides/signature.py:61: in _is_same_module
mod2 = mod2.split(".")[0]
E AttributeError: 'NoneType' object has no attribute 'split'
from overrides.
Method descriptors don't exist in pypy, instead we have regular function objects, but with
__module__
set to None
Could we remove the __module__
attribute from methods on builtins?
from overrides.
So I guess the fix here is to check for None
as well as AttributeError
from overrides.
yeah, pypy could try to make sure that the methods of builtins raise an error when reading __module__
instead of returning None
. I can give that a try
from overrides.
that said, the __module__
attribute of builtin functions (eg abs
) is "builtin"
in both pypy and cpython, maybe we should simply adopt that for builtin methods too? Anyone have an opinion on either of these options?
from overrides.
I don't know whether it's worth changing this in PyPy — either way, I'll try making a PR to support both missing and None
attribute, if only to support prior PyPy versions.
from overrides.
Thank you all for informing, debugging and solving the issue!
from overrides.
Related Issues (20)
- Failed when overriding a decorated function HOT 4
- Feature request: allow renaming unused variables HOT 2
- Inner classes are recognized as methods by EnforceOverrides HOT 4
- Sic .. so maybe override also? HOT 1
- Does `override` need to be overloaded explicitly? HOT 3
- Do some caching of base lookup HOT 1
- `overrides` is incompatible with `nuitka` HOT 1
- False positive when checking parameter with Callable HOT 25
- Error when using pipe for union types HOT 3
- tests/test_enforce__py38.py::EnforceTests::test_enforcing_when_incompatible fails with Python 3.12 HOT 6
- Docs request: IDE linting guidance HOT 1
- Regression in version 7.6.0 when base class name has more than one level of nesting HOT 3
- `AttributeError` from `overrides` in conjunction with `typing_extensions.Literal` in subclass HOT 2
- Move away from `distutils`: please migrate to `pyproject.toml`
- @overrides cause maximum recursion depth exceeded when input argument has Literal HOT 10
- Overrides breakes SOLID Liskov rule? HOT 1
- TypedDict is treated as different class as Dict[str, Any] HOT 5
- `threading.Lock` is not recognized as a `ContextManager` HOT 1
- TypeError: DictionaryField.batch_tensors: `tensor_list` is not present. 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 overrides.