mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
31 lines
655 B
Python
31 lines
655 B
Python
#
|
|
# This file is distributed under the MIT License. See LICENSE.md for details.
|
|
#
|
|
|
|
"""
|
|
CABC: Compatibility ABCs.
|
|
|
|
This is needed to support proper type checking, but
|
|
avoid metaclasses which we should avoid on classes we intend of implementing in
|
|
C++.
|
|
"""
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from abc import ABC, abstractmethod
|
|
else:
|
|
|
|
class ABC:
|
|
pass
|
|
|
|
def abstractmethod(func):
|
|
# Import it inside so users cannot import it by mistake
|
|
from functools import wraps
|
|
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
raise NotImplementedError("Abstract method")
|
|
|
|
return wrapper
|