brain_uuid.py 678 B

123456789101112131415161718
  1. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  2. # For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
  3. # Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
  4. """Astroid hooks for the UUID module."""
  5. from astroid import nodes
  6. from astroid.manager import AstroidManager
  7. def _patch_uuid_class(node: nodes.ClassDef) -> None:
  8. # The .int member is patched using __dict__
  9. node.locals["int"] = [nodes.Const(0, parent=node)]
  10. def register(manager: AstroidManager) -> None:
  11. manager.register_transform(
  12. nodes.ClassDef, _patch_uuid_class, lambda node: node.qname() == "uuid.UUID"
  13. )