Skip to content

Commit 0c1f104

Browse files
authored
Various minor docstring and comment updates (#19519)
Mostly grammar improvements.
1 parent a8d2f13 commit 0c1f104

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

mypy/build.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def default_flush_errors(
194194
result.errors = messages
195195
return result
196196
except CompileError as e:
197-
# CompileErrors raised from an errors object carry all of the
197+
# CompileErrors raised from an errors object carry all the
198198
# messages that have not been reported out by error streaming.
199199
# Patch it up to contain either none or all none of the messages,
200200
# depending on whether we are flushing errors.
@@ -802,11 +802,11 @@ def correct_rel_imp(imp: ImportFrom | ImportAll) -> str:
802802
res.append((pri, sub_id, imp.line))
803803
else:
804804
all_are_submodules = False
805-
# Add cur_id as a dependency, even if all of the
805+
# Add cur_id as a dependency, even if all the
806806
# imports are submodules. Processing import from will try
807807
# to look through cur_id, so we should depend on it.
808-
# As a workaround for for some bugs in cycle handling (#4498),
809-
# if all of the imports are submodules, do the import at a lower
808+
# As a workaround for some bugs in cycle handling (#4498),
809+
# if all the imports are submodules, do the import at a lower
810810
# priority.
811811
pri = import_priority(imp, PRI_HIGH if not all_are_submodules else PRI_LOW)
812812
res.append((pri, cur_id, imp.line))
@@ -929,7 +929,7 @@ def write_deps_cache(
929929
) -> None:
930930
"""Write cache files for fine-grained dependencies.
931931
932-
Serialize fine-grained dependencies map for fine grained mode.
932+
Serialize fine-grained dependencies map for fine-grained mode.
933933
934934
Dependencies on some module 'm' is stored in the dependency cache
935935
file m.deps.json. This entails some spooky action at a distance:
@@ -943,7 +943,7 @@ def write_deps_cache(
943943
fine-grained dependencies in a global cache file:
944944
* We take a snapshot of current sources to later check consistency
945945
between the fine-grained dependency cache and module cache metadata
946-
* We store the mtime of all of the dependency files to verify they
946+
* We store the mtime of all the dependency files to verify they
947947
haven't changed
948948
"""
949949
metastore = manager.metastore
@@ -1111,7 +1111,7 @@ def read_deps_cache(manager: BuildManager, graph: Graph) -> dict[str, FgDepMeta]
11111111
if deps_meta is None:
11121112
return None
11131113
meta_snapshot = deps_meta["snapshot"]
1114-
# Take a snapshot of the source hashes from all of the metas we found.
1114+
# Take a snapshot of the source hashes from all the metas we found.
11151115
# (Including the ones we rejected because they were out of date.)
11161116
# We use this to verify that they match up with the proto_deps.
11171117
current_meta_snapshot = {

mypyc/build.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ def build_using_shared_lib(
270270
) -> list[Extension]:
271271
"""Produce the list of extension modules when a shared library is needed.
272272
273-
This creates one shared library extension module that all of the
274-
others import and then one shim extension module for each
275-
module in the build, that simply calls an initialization function
273+
This creates one shared library extension module that all the
274+
others import, and one shim extension module for each
275+
module in the build. Each shim simply calls an initialization function
276276
in the shared library.
277277
278-
The shared library (which lib_name is the name of) is a python
278+
The shared library (which lib_name is the name of) is a Python
279279
extension module that exports the real initialization functions in
280280
Capsules stored in module attributes.
281281
"""
@@ -511,7 +511,7 @@ def mypycify(
511511
separate: Should compiled modules be placed in separate extension modules.
512512
If False, all modules are placed in a single shared library.
513513
If True, every module is placed in its own library.
514-
Otherwise separate should be a list of
514+
Otherwise, separate should be a list of
515515
(file name list, optional shared library name) pairs specifying
516516
groups of files that should be placed in the same shared library
517517
(while all other modules will be placed in its own library).

mypyc/codegen/emitmodule.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Generate C code for a Python C extension module from Python source code."""
22

33
# FIXME: Basically nothing in this file operates on the level of a
4-
# single module and it should be renamed.
4+
# single module and it should be renamed.
55

66
from __future__ import annotations
77

@@ -71,7 +71,7 @@
7171
from mypyc.transform.spill import insert_spills
7272
from mypyc.transform.uninit import insert_uninit_checks
7373

74-
# All of the modules being compiled are divided into "groups". A group
74+
# All the modules being compiled are divided into "groups". A group
7575
# is a set of modules that are placed into the same shared library.
7676
# Two common configurations are that every module is placed in a group
7777
# by itself (fully separate compilation) and that every module is
@@ -164,7 +164,7 @@ def report_config_data(self, ctx: ReportConfigContext) -> tuple[str | None, list
164164
if hash_digest(meta_json) != ir_data["meta_hash"]:
165165
return None
166166

167-
# Check that all of the source files are present and as
167+
# Check that all the source files are present and as
168168
# expected. The main situation where this would come up is the
169169
# user deleting the build directory without deleting
170170
# .mypy_cache, which we should handle gracefully.
@@ -215,8 +215,8 @@ def compile_scc_to_ir(
215215
) -> ModuleIRs:
216216
"""Compile an SCC into ModuleIRs.
217217
218-
Any modules that this SCC depends on must have either compiled or
219-
loaded from a cache into mapper.
218+
Any modules that this SCC depends on must have either been compiled,
219+
type checked, or loaded from a cache into mapper.
220220
221221
Arguments:
222222
scc: The list of MypyFiles to compile
@@ -244,11 +244,11 @@ def compile_scc_to_ir(
244244

245245
for module in modules.values():
246246
for fn in module.functions:
247-
# Insert uninit checks.
247+
# Insert checks for uninitialized values.
248248
insert_uninit_checks(fn)
249249
# Insert exception handling.
250250
insert_exception_handling(fn)
251-
# Insert refcount handling.
251+
# Insert reference count handling.
252252
insert_ref_count_opcodes(fn)
253253

254254
if fn in env_user_functions:
@@ -369,7 +369,7 @@ def write_cache(
369369
cache are in sync and refer to the same version of the code.
370370
This is particularly important if mypyc crashes/errors/is
371371
stopped after mypy has written its cache but before mypyc has.
372-
* The hashes of all of the source file outputs for the group
372+
* The hashes of all the source file outputs for the group
373373
the module is in. This is so that the module will be
374374
recompiled if the source outputs are missing.
375375
"""
@@ -429,7 +429,7 @@ def compile_modules_to_c(
429429
Each shared library module provides, for each module in its group,
430430
a PyCapsule containing an initialization function.
431431
Additionally, it provides a capsule containing an export table of
432-
pointers to all of the group's functions and static variables.
432+
pointers to all the group's functions and static variables.
433433
434434
Arguments:
435435
result: The BuildResult from the mypy front-end
@@ -504,16 +504,15 @@ def __init__(
504504
505505
The code for a compilation group contains an internal and an
506506
external .h file, and then one .c if not in multi_file mode or
507-
one .c file per module if in multi_file mode.)
507+
one .c file per module if in multi_file mode.
508508
509509
Arguments:
510510
modules: (name, ir) pairs for each module in the group
511511
source_paths: Map from module names to source file paths
512512
group_name: The name of the group (or None if this is single-module compilation)
513513
group_map: A map of modules to their group names
514514
names: The name generator for the compilation
515-
multi_file: Whether to put each module in its own source file regardless
516-
of group structure.
515+
compiler_options: Mypyc specific options, including multi_file mode
517516
"""
518517
self.modules = modules
519518
self.source_paths = source_paths
@@ -642,7 +641,7 @@ def generate_c_for_modules(self) -> list[tuple[str, str]]:
642641
decls = ext_declarations if declaration.is_type else declarations
643642
if not declaration.is_type:
644643
decls.emit_lines(f"extern {declaration.decl[0]}", *declaration.decl[1:])
645-
# If there is a definition, emit it. Otherwise repeat the declaration
644+
# If there is a definition, emit it. Otherwise, repeat the declaration
646645
# (without an extern).
647646
if declaration.defn:
648647
emitter.emit_lines(*declaration.defn)
@@ -770,13 +769,13 @@ def generate_export_table(self, decl_emitter: Emitter, code_emitter: Emitter) ->
770769
def generate_shared_lib_init(self, emitter: Emitter) -> None:
771770
"""Generate the init function for a shared library.
772771
773-
A shared library contains all of the actual code for a
772+
A shared library contains all the actual code for a
774773
compilation group.
775774
776775
The init function is responsible for creating Capsules that
777776
wrap pointers to the initialization function of all the real
778777
init functions for modules in this shared library as well as
779-
the export table containing all of the exported functions and
778+
the export table containing all the exported functions and
780779
values from all the modules.
781780
782781
These capsules are stored in attributes of the shared library.

0 commit comments

Comments
 (0)