MCPcopy
hub / github.com/psf/black / dump

Method dump

src/blib2to3/pgen2/grammar.py:100–115  ·  view source on GitHub ↗

Dump the grammar tables to a pickle file.

(self, filename: Path)

Source from the content-addressed store, hash-verified

98 self.async_keywords = False
99
100 def dump(self, filename: Path) -> None:
101 """Dump the grammar tables to a pickle file."""
102
103 # mypyc generates objects that don't have a __dict__, but they
104 # do have __getstate__ methods that will return an equivalent
105 # dictionary
106 if hasattr(self, "__dict__"):
107 d = self.__dict__
108 else:
109 d = self.__getstate__() # type: ignore
110
111 with tempfile.NamedTemporaryFile(
112 dir=os.path.dirname(filename), delete=False
113 ) as f:
114 pickle.dump(d, f, pickle.HIGHEST_PROTOCOL)
115 os.replace(f.name, filename)
116
117 def _update(self, attrs: dict[str, Any]) -> None:
118 for k, v in attrs.items():

Callers 2

load_grammarFunction · 0.95
writeMethod · 0.80

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected