brain_uuid.py 667 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/PyCQA/astroid/blob/main/LICENSE
  3. # Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt
  4. """Astroid hooks for the UUID module."""
  5. from astroid.manager import AstroidManager
  6. from astroid.nodes.node_classes import Const
  7. from astroid.nodes.scoped_nodes import ClassDef
  8. def _patch_uuid_class(node: ClassDef) -> None:
  9. # The .int member is patched using __dict__
  10. node.locals["int"] = [Const(0, parent=node)]
  11. AstroidManager().register_transform(
  12. ClassDef, _patch_uuid_class, lambda node: node.qname() == "uuid.UUID"
  13. )