question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Human-readable exception messages for incorrectly chained decorators

See original GitHub issue
from beartype import beartype
class Bar:
    @beartype
    @classmethod
    def foo(cls, s: str) -> int:
        return int(s)

gives <classmethod object at 0x7f68d6e9fbb0> uncallable

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TeamSpen210commented, Jan 1, 2022

For property there are potentially 3 functions you need to wrap - .fget, .fset and .fdel. If not set they’re None, so you’ll need to not wrap in that case. Once you’ve wrapped them pass to the property constructor, plus doc=old.__doc__ to keep whatever was chosen.

1reaction
qiujiangkuncommented, Jan 1, 2022

How about extracting the underlying function and re-annotate with classmethod and staticmethod? I’m currently using this approch. But it doesn’t work for @property


if isinstance(value, classmethod):
    attr[name] = classmethod(beartype(value.__func__))
elif isinstance(value, staticmethod):
    attr[name] = staticmethod(beartype(value.__func__))
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make mistakes in Python - O'Reilly
In modern Python, properties are constructed with the @property decorator, which is just syntactic sugar for a function that replaces a method ...
Read more >
API — Click Documentation (8.1.x)
Create a decorator that passes a key from click.Context.meta as the first argument to the decorated function. Parameters. key (str) – Key in ......
Read more >
Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >
RHSA-2022:0056 - Security Advisory - Red Hat 客户门户网站
描述. Red Hat OpenShift Container Platform is Red Hat's cloud computing. Kubernetes application platform solution designed for on-premise or ...
Read more >
Jakarta Bean Validation specification
The specification uses Java 8 language features. ... public @interface FrenchZipCode { String message() default "Wrong zip code"; Class<?> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found