brain_uuid.py 851 B

12345678910111213141516171819202122
  1. # Copyright (c) 2017-2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
  2. # Copyright (c) 2020-2021 hippo91 <guillaume.peillex@gmail.com>
  3. # Copyright (c) 2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
  4. # Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
  5. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  6. # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
  7. """Astroid hooks for the UUID module."""
  8. from astroid.manager import AstroidManager
  9. from astroid.nodes.node_classes import Const
  10. from astroid.nodes.scoped_nodes import ClassDef
  11. def _patch_uuid_class(node):
  12. # The .int member is patched using __dict__
  13. node.locals["int"] = [Const(0, parent=node)]
  14. AstroidManager().register_transform(
  15. ClassDef, _patch_uuid_class, lambda node: node.qname() == "uuid.UUID"
  16. )