[PATCH 15 of 24 yams V2] [misc] simplify code

Laurent Peuch cortex at worlddomination.be
Wed Mar 4 15:17:51 CET 2020


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1580232810 -3600
#      Tue Jan 28 18:33:30 2020 +0100
# Node ID e17b76d216a4c7cfe5eb73a9ecf6543ff9b890c1
# Parent  47dd2a02498cf7beace106c0743d2222105ed74b
# Available At https://hg.logilab.org/users/lpeuch/yams
#              hg pull https://hg.logilab.org/users/lpeuch/yams -r e17b76d216a4
# EXP-Topic type_annotations
[misc] simplify code

diff --git a/yams/schema2dot.py b/yams/schema2dot.py
--- a/yams/schema2dot.py
+++ b/yams/schema2dot.py
@@ -122,10 +122,8 @@ class FullSchemaVisitor(SchemaVisitor):
     def __init__(self, schema, skiptypes=()):
         super(FullSchemaVisitor, self).__init__(skiptypes)
         self.schema = schema
-        self._eindex = None
-        entities = [eschema for eschema in schema.entities()
-                    if self.should_display_schema(eschema)]
-        self._eindex = dict([(e.type, e) for e in entities])
+        self._eindex = {eschema.type: eschema for eschema in schema.entities()
+                        if self.should_display_schema(eschema)}
 
     def nodes(self):
         for eschema in sorted(self._eindex.values(), key=lambda x: x.type):



More information about the cubicweb-devel mailing list