File: _internal.py

package info (click to toggle)
python-polyfactory 2.22.2-3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,892 kB
  • sloc: python: 11,338; makefile: 102; sh: 38
file content (8 lines) | stat: -rw-r--r-- 353 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
def is_attribute_overridden(base: type, cls: type, attribute_name: str) -> bool:
    """Return True if attribute is overridden by any ancestor before reaching base in the MRO."""
    for ancestor in cls.mro():
        if ancestor is base:
            return False
        if attribute_name in ancestor.__dict__:
            return True
    return False