Skip to content

Commit 78356b5

Browse files
benmssbehnazh-w
authored andcommitted
chore: misc fixes
Signed-off-by: Ben Selwyn-Smith <[email protected]>
1 parent f651037 commit 78356b5

File tree

13 files changed

+81
-81
lines changed

13 files changed

+81
-81
lines changed

src/macaron/build_spec_generator/build_command_patcher.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ def patch_commands(
9999
100100
For each command in this command sequence:
101101
102-
- If the command is not a build command or the build tool is not supported by us, it will be leave intact.
102+
- If the command is not a build command, or it's a tool we do not support, it will be left intact.
103103
104-
- If the command is a build command supported by us, it will be patch if a patch value is provided to ``patches``.
105-
If no patch value is provided for a build command, it will be leave intact.
104+
- If the command is a build command we support, it will be patched, if a patch value is provided in ``patches``.
105+
If no patch value is provided for a build command, it will be left intact.
106106
107107
`patches` is a mapping with:
108108
@@ -113,7 +113,7 @@ def patch_commands(
113113
For example: :class:`macaron.cli_command_parser.maven_cli_parser.MavenCLICommandParser.apply_patch`,
114114
:class:`macaron.cli_command_parser.gradle_cli_parser.GradleCLICommandParser.apply_patch`.
115115
116-
This means that all commands that matches a BuildTool will be apply by the same patch value.
116+
This means that all commands that match a BuildTool will be applied by the same patch value.
117117
118118
Returns
119119
-------

src/macaron/build_spec_generator/build_spec_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
class BuildSpecFormat(str, Enum):
23-
"""The build spec format that we supports."""
23+
"""The build spec formats that we support."""
2424

2525
REPRODUCIBLE_CENTRAL = "rc-buildspec"
2626

@@ -87,7 +87,7 @@ def gen_build_spec_for_purl(
8787
int
8888
The exit code for this function. ``os.EX_OK`` if everything is fine, ``os.EX_OSERR`` if the
8989
buildspec file cannot be created in the local filesystem, ``os.EX_DATAERR`` if there was an
90-
error in generate the content for the buildspec file.
90+
error generating the content for the buildspec file.
9191
"""
9292
db_engine = create_engine(f"sqlite+pysqlite:///{database_path}", echo=False)
9393

@@ -102,7 +102,7 @@ def gen_build_spec_for_purl(
102102
)
103103

104104
if not build_spec_content:
105-
logger.error("Error while generate reproducible central build spec.")
105+
logger.error("Error while generating reproducible central build spec.")
106106
return os.EX_DATAERR
107107

108108
logger.debug("Build spec content: \n%s", build_spec_content)
@@ -133,7 +133,7 @@ def gen_build_spec_for_purl(
133133
file.write(build_spec_content)
134134
except OSError as error:
135135
logger.error(
136-
"Could not generate the Buildspec to %s. Error: %s",
136+
"Could not create the build spec at %s. Error: %s",
137137
os.path.relpath(build_spec_filepath, os.getcwd()),
138138
error,
139139
)

src/macaron/build_spec_generator/cli_command_parser/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def is_list_of_strs(value: Any) -> TypeGuard[list[str]]:
1717

1818

1919
def is_dict_of_str_to_str_or_none(value: Any) -> TypeGuard[dict[str, str | None]]:
20-
"""Type guard for a dictionary with keys are string and values are strings or None."""
20+
"""Type guard for a dictionary where the keys are string and values are strings or None."""
2121
if not isinstance(value, dict):
2222
return False
2323

@@ -37,7 +37,7 @@ def patch_mapping(
3737
) -> dict[str, str]:
3838
"""Patch a mapping.
3939
40-
A key with value in patch set to None will be removed from the original.
40+
A key with a value in the patch set to None will be removed from the original.
4141
4242
Parameters
4343
----------
@@ -79,7 +79,7 @@ class OptionDef(Generic[P]):
7979

8080
@abstractmethod
8181
def is_valid_patch_option(self, patch: Any) -> TypeGuard[P]:
82-
"""Return True if the provide patch value is compatible with the internal type of this option."""
82+
"""Return True if the provided patch value is compatible with the internal type of this option."""
8383
raise NotImplementedError()
8484

8585
@abstractmethod
@@ -162,4 +162,4 @@ def apply_patch(
162162
cli_command: T,
163163
options_patch: Mapping[str, Y_contra | None],
164164
) -> T:
165-
"""Return the a new CLICommand object with its option patched, while persisting the executable path."""
165+
"""Return a new CLICommand object with its option patched, while persisting the executable path."""

src/macaron/build_spec_generator/cli_command_parser/gradle_cli_command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,17 @@ def from_parsed_arg(
139139
def parse_properties(props: list[str]) -> dict[str, str]:
140140
"""Return a dictionary that maps between a property and its value.
141141
142-
Each property definition value in `props` can have either of these format:
142+
Each property definition value in `props` can have either of these formats:
143143
- `property=value` (e.g. `property=value` from `-Dproperty=value`): this will
144144
be parsed into a dictionary mapping of `"property": "value"`.
145-
Both the key and value of this mapping is of type string.
145+
Both the key and value of this mapping are of type string.
146146
- `property` (e.g. `property` from `-Dproperty`): this will be parsed into a
147147
dictionary mapping of `"property": <empty_string>`.
148148
149149
Parameters
150150
----------
151151
props: list[str]
152-
The list of properties definition provided in the cli command.
152+
The list of property definitions provided in the cli command.
153153
This is the list parsed by argparse.
154154
155155
Returns

src/macaron/build_spec_generator/cli_command_parser/gradle_cli_parser.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class GradleOptionalFlag(OptionDef[bool]):
4747
dest: str | None = field(default=None)
4848

4949
def is_valid_patch_option(self, patch: Any) -> TypeGuard[bool]:
50-
"""Return True if the provide patch value is compatible with the internal type of this option."""
50+
"""Return True if the provided patch value is compatible with the internal type of this option."""
5151
return isinstance(patch, bool)
5252

5353
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -76,7 +76,7 @@ def get_patch_type_str(self) -> str:
7676

7777
@dataclass
7878
class GradleOptionalNegateableFlag(OptionDef[bool]):
79-
"""This option represents an optional negateable flag in Gradle CLI command.
79+
"""This option represents an optional negatable flag in Gradle CLI command.
8080
8181
For example: --build-cache/--no-build-cache
8282
"""
@@ -119,12 +119,12 @@ def get_patch_type_str(self) -> str:
119119

120120
@dataclass
121121
class GradleSingleValue(OptionDef[str]):
122-
"""This option represents an option that takes a value in Grale CLI command."""
122+
"""This option represents an option that takes a value in Gradle CLI command."""
123123

124124
short_name: str | None
125125

126126
def is_valid_patch_option(self, patch: Any) -> TypeGuard[str]:
127-
"""Return True if the provide patch value is compatible with the internal type of this option."""
127+
"""Return True if the provided patch value is compatible with the internal type of this option."""
128128
return isinstance(patch, str)
129129

130130
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -145,10 +145,10 @@ def get_patch_type_str(self) -> str:
145145

146146
@dataclass
147147
class GradlePropeties(OptionDef[dict[str, str | None]]):
148-
"""This option represents an option used to define properties values of a Gradle CLI command.
148+
"""This option represents an option used to define property values of a Gradle CLI command.
149149
150150
This option can be defined multiple times and the values are appended into a list of string in argparse.
151-
However, it's stored internally as a dictionary mapping between the system property name to its value.
151+
However, it's stored internally as a dictionary mapping between the system property name and its value.
152152
153153
In Gradle there are 2 options of this type:
154154
- -D/--system-prop
@@ -158,7 +158,7 @@ class GradlePropeties(OptionDef[dict[str, str | None]]):
158158
short_name: str
159159

160160
def is_valid_patch_option(self, patch: Any) -> TypeGuard[dict[str, str | None]]:
161-
"""Return True if the provide patch value is compatible with the internal type of this option."""
161+
"""Return True if the provided patch value is compatible with the internal type of this option."""
162162
return is_dict_of_str_to_str_or_none(patch)
163163

164164
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -181,7 +181,7 @@ class GradleTask(OptionDef[list[str]]):
181181
"""
182182

183183
def is_valid_patch_option(self, patch: Any) -> TypeGuard[list[str]]:
184-
"""Return True if the provide patch value is compatible with the internal type of this option."""
184+
"""Return True if the provided patch value is compatible with the internal type of this option."""
185185
return is_list_of_strs(patch)
186186

187187
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -199,16 +199,17 @@ def get_patch_type_str(self) -> str:
199199

200200
@dataclass
201201
class GradleAppendedList(OptionDef[list[str]]):
202-
"""This option represents an option that can be specify multiple times and they all appended to a list.
202+
"""This option represents an option that can be specified multiple times.
203203
204-
For example, one can exclude multiple tasks with
205-
gradle <task_to_run> --exclude-task taskA --exclude-task taskB
204+
Each instance of the option will be appended to a list.
205+
For example, one can exclude multiple tasks with:
206+
gradle <task_to_run> --exclude-task taskA --exclude-task taskB
206207
"""
207208

208209
short_name: str
209210

210211
def is_valid_patch_option(self, patch: Any) -> TypeGuard[list[str]]:
211-
"""Return True if the provide patch value is compatible with the internal type of this option."""
212+
"""Return True if the provided patch value is compatible with the internal type of this option."""
212213
return is_list_of_strs(patch)
213214

214215
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -223,7 +224,7 @@ def get_patch_type_str(self) -> str:
223224
return "list[str]"
224225

225226

226-
# TODO: some value option only allows you to provide certain values
227+
# TODO: some value options only allow you to provide certain values.
227228
# For example: --console allows "plain", "auto", "rich" or "verbose".
228229
# They are right now not enforced. We need to think whether we want to enforce them.
229230
GRADLE_OPTION_DEF: list[OptionDef] = [
@@ -368,7 +369,7 @@ def get_patch_type_str(self) -> str:
368369
short_name="-x",
369370
long_name="--exclude-task",
370371
),
371-
# TODO: determine which of these options can be provided multiple times
372+
# TODO: determine which of these options can be provided multiple times.
372373
GradleSingleValue(
373374
short_name="-b",
374375
long_name="--build-file",
@@ -583,7 +584,7 @@ def apply_patch(
583584
584585
`options_patch` is a mapping with:
585586
586-
- **Key**: the long name of an Gradle CLI option as string. For example: ``--continue``, ``--build-cache``.
587+
- **Key**: the long name of a Gradle CLI option as string. For example: ``--continue``, ``--build-cache``.
587588
For patching tasks, use the key ``tasks``.
588589
589590
- **Value**: The value to patch for an option referred to by the key. The type of this value
@@ -660,7 +661,7 @@ def apply_option_patch(
660661
if not self.validate_patch(patch):
661662
raise PatchBuildCommandError("The patch is invalid.")
662663

663-
# Copy the Maven CLI Options for patching
664+
# Copy the Maven CLI Options for patching.
664665
new_gradle_cli_options = deepcopy(gradle_cli_options)
665666

666667
for option_long_name, patch_value in patch.items():

src/macaron/build_spec_generator/cli_command_parser/maven_cli_command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def from_parsed_arg(
6060
cls,
6161
parsed_arg: argparse.Namespace,
6262
) -> "MavenCLIOptions":
63-
"""Initialize the instance from the the argparse.Namespace object.
63+
"""Initialize the instance from the argparse.Namespace object.
6464
6565
Parameters
6666
----------
@@ -142,8 +142,8 @@ def parse_system_properties(props: list[str]) -> dict[str, str]:
142142
system_props = {}
143143
for ele in props:
144144
prop_name, _, prop_val = ele.partition("=")
145-
# Allow the subsequent definition override the previous one.
146-
# This follows the way Maven is resolving system property.
145+
# Allow subsequent definitions to override previous ones.
146+
# This follows the way Maven resolves system properties.
147147
# For example:
148148
# mvn help:evaluate -Da=foo -Da=bar -Dexpression=a -q -DforceStdout
149149
# => result for `a` is bar

src/macaron/build_spec_generator/cli_command_parser/maven_cli_parser.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MavenOptionalFlag(OptionDef[bool]):
3333
3434
For example: --debug/-X
3535
36-
A short form for the option is rquired.
36+
A short form for the option is required.
3737
"""
3838

3939
short_name: str
@@ -43,7 +43,7 @@ class MavenOptionalFlag(OptionDef[bool]):
4343
dest: str | None = field(default=None)
4444

4545
def is_valid_patch_option(self, patch: Any) -> TypeGuard[bool]:
46-
"""Return True if the provide patch value is compatible with the internal type of this option."""
46+
"""Return True if the provided patch value is compatible with the internal type of this option."""
4747
return isinstance(patch, bool)
4848

4949
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -77,7 +77,7 @@ class MavenSingleValue(OptionDef[str]):
7777
short_name: str
7878

7979
def is_valid_patch_option(self, patch: Any) -> TypeGuard[str]:
80-
"""Return True if the provide patch value is compatible with the internal type of this option."""
80+
"""Return True if the provided patch value is compatible with the internal type of this option."""
8181
return isinstance(patch, str)
8282

8383
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -96,19 +96,19 @@ class MavenCommaDelimList(OptionDef[list[str]]):
9696
"""This option represents an option that takes a comma delimited value in Maven CLI command.
9797
9898
This option can be defined one time only and the value is stored as a string in argparse.
99-
However, it's stored internally as list of strings obtained by spliting its original value in argparse
99+
However, it's stored internally as list of strings obtained by splitting its original value in argparse
100100
using comma as the delimiter.
101101
102102
For example: "-P profile1,profile2,profile3"
103-
will be store as ["profile1", "profile2", "profile3"]
103+
will be stored as ["profile1", "profile2", "profile3"]
104104
105105
A short form for the option is required.
106106
"""
107107

108108
short_name: str
109109

110110
def is_valid_patch_option(self, patch: Any) -> TypeGuard[list[str]]:
111-
"""Return True if the provide patch value is compatible with the internal type of this option."""
111+
"""Return True if the provided patch value is compatible with the internal type of this option."""
112112
return is_list_of_strs(patch)
113113

114114
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -138,7 +138,7 @@ class MavenSystemPropeties(OptionDef[dict[str, str | None]]):
138138
short_name: str
139139

140140
def is_valid_patch_option(self, patch: Any) -> TypeGuard[dict[str, str | None]]:
141-
"""Return True if the provide patch value is compatible with the internal type of this option."""
141+
"""Return True if the provided patch value is compatible with the internal type of this option."""
142142
return is_dict_of_str_to_str_or_none(patch)
143143

144144
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -161,7 +161,7 @@ class MavenGoalPhase(OptionDef[list[str]]):
161161
"""
162162

163163
def is_valid_patch_option(self, patch: Any) -> TypeGuard[list[str]]:
164-
"""Return True if the provide patch value is compatible with the internal type of this option."""
164+
"""Return True if the provided patch value is compatible with the internal type of this option."""
165165
return is_list_of_strs(patch)
166166

167167
def add_itself_to_arg_parser(self, arg_parse: argparse.ArgumentParser) -> None:
@@ -280,7 +280,7 @@ def get_patch_type_str(self) -> str:
280280
long_name="goals",
281281
),
282282
# TODO: we need to confirm whether one can provide
283-
# -P or -pl multiple times and the values will be aggregate into a list of string
283+
# -P or -pl multiple times and the values will be aggregate into a list of string.
284284
# The current implementation only consider one instance of -P or -pl.
285285
# Where to begin:
286286
# https://github.com/apache/maven/blob/maven-3.9.x/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
@@ -360,7 +360,7 @@ def __init__(self) -> None:
360360
exit_on_error=False,
361361
)
362362

363-
# A mapping between the long name to its option definition.
363+
# A mapping between the long name and its option definition.
364364
self.option_defs: dict[str, OptionDef] = {}
365365

366366
for opt_def in MAVEN_OPTION_DEF:
@@ -452,7 +452,7 @@ def parse(self, cmd_list: list[str]) -> "MavenCLICommand":
452452
# mvn --help
453453
# mvn --version
454454
# Note that we don't allow mvn -V or mvn --show-version as this command will
455-
# failed for mvn
455+
# fail for mvn.
456456
if not parsed_opts.help_ and not parsed_opts.version:
457457
raise CommandLineParseError(f"No goal detected for {' '.join(options)}.")
458458

@@ -491,10 +491,9 @@ def apply_patch(
491491
`options_patch` is a mapping with:
492492
493493
- **Key**: the long name of a Maven CLI option as a string. For example: ``--define``, ``--settings``.
494-
For patching goals or plugin phases, use the key `goals` with value being a list of string.
494+
For patching goals or plugin phases, use the key `goals` with the value being a list of strings.
495495
496-
- **Value**: The value to patch. The type of this value depends on the type of option you want to
497-
patch.
496+
- **Value**: The value to patch. The type of this value depends on the type of option to be patched.
498497
499498
The types of patch values:
500499

src/macaron/build_spec_generator/cli_command_parser/unparsed_cli_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
@dataclass
1010
class UnparsedCLICommand:
11-
"""This class represents a CLICommand that we don't support parsing.
11+
"""This class represents a CLICommand that we support the parsing of.
1212
13-
Therefore, it only stores the original command as is.
13+
It is stored in its original form.
1414
"""
1515

1616
original_cmds: list[str]

0 commit comments

Comments
 (0)