Skip to content

Commit 3cc554e

Browse files
ytauschCopilotbeckermr
authored
enforce numpydoc with ruff (#4214)
* style(ruff): lint docstrings * style(ruff): run safe auto-fixes * style(ruff): apply unsafe fixes * fix remaining ruff errors manually * manually convert some docstrings * convert more to numpydoc * fix: grammar Co-authored-by: Copilot <[email protected]> * replaceall remaining docstrings * remove redundant types * fix some tests * revert: convert back to RuntimeError * fix: use existing path everywhere * various fixes * fix test * update schema --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Matthew R. Becker <[email protected]>
1 parent 279b253 commit 3cc554e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1264
-663
lines changed

conda_forge_tick/auto_tick.py

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,21 @@ def _prepare_feedstock_repository(
156156
157157
Any errors are written to the pr_info attribute of the feedstock context and logged.
158158
159-
:param backend: The GitPlatformBackend instance to use.
160-
:param context: The current context
161-
:param branch: The branch to create in the forked repository.
162-
:param base_branch: The base branch to branch from.
163-
:return: True if the repository was successfully prepared, False otherwise.
159+
Parameters
160+
----------
161+
backend
162+
The GitPlatformBackend instance to use.
163+
context
164+
The current context
165+
branch
166+
The branch to create in the forked repository.
167+
base_branch
168+
The base branch to branch from.
169+
170+
Returns
171+
-------
172+
bool
173+
True if the repository was successfully prepared, False otherwise.
164174
"""
165175
try:
166176
backend.fork(context.git_repo_owner, context.git_repo_name)
@@ -201,12 +211,24 @@ def _commit_migration(
201211
"""
202212
Commit a migration that has been run in the local clone of a feedstock repository.
203213
If an error occurs during the commit, it is logged.
204-
:param cli: The GitCli instance to use.
205-
:param context: The FeedstockContext instance.
206-
:param commit_message: The commit message to use.
207-
:param allow_empty_commits: Whether the migrator allows empty commits.
208-
:param raise_commit_errors: Whether to raise an exception if an error occurs during the commit.
209-
:raises GitCliError: If an error occurs during the commit and raise_commit_errors is True.
214+
215+
Parameters
216+
----------
217+
cli
218+
The GitCli instance to use.
219+
context
220+
The FeedstockContext instance.
221+
commit_message
222+
The commit message to use.
223+
allow_empty_commits
224+
Whether the migrator allows empty commits.
225+
raise_commit_errors
226+
Whether to raise an exception if an error occurs during the commit.
227+
228+
Raises
229+
------
230+
GitCliError
231+
If an error occurs during the commit and raise_commit_errors is True.
210232
"""
211233
cli.add(
212234
context.local_clone_dir,
@@ -226,9 +248,7 @@ def _commit_migration(
226248

227249
@dataclass(frozen=True)
228250
class _RerenderInfo:
229-
"""
230-
Additional information about a rerender operation.
231-
"""
251+
"""Additional information about a rerender operation."""
232252

233253
nontrivial_changes: bool
234254
"""
@@ -292,10 +312,17 @@ def _should_automerge(migrator: Migrator, context: FeedstockContext) -> bool:
292312
"""
293313
Determine if a migration should be auto merged based on the feedstock and migrator settings.
294314
295-
:param migrator: The migrator to check.
296-
:param context: The feedstock context.
315+
Parameters
316+
----------
317+
migrator
318+
The migrator to check.
319+
context
320+
The feedstock context.
297321
298-
:return: True if the migrator should be auto merged, False otherwise.
322+
Returns
323+
-------
324+
bool
325+
True if the migrator should be auto merged, False otherwise.
299326
"""
300327
if isinstance(migrator, Version):
301328
return context.automerge in [True, "version"]
@@ -396,12 +423,20 @@ def _check_and_process_solvability(
396423
by setting the corresponding fields in the feedstock attributes.
397424
If the recipe is solvable, reset the fields that track the solvability check status.
398425
399-
:param migrator: The migrator that was run
400-
:param context: The current FeedstockContext of the feedstock that was migrated
401-
:param base_branch: The branch of the feedstock repository that is the migration target
426+
Parameters
427+
----------
428+
migrator
429+
The migrator that was run
430+
context
431+
The current FeedstockContext of the feedstock that was migrated
432+
base_branch
433+
The branch of the feedstock repository that is the migration target
402434
403-
:returns: True if the migration can proceed normally, False if a required solvability check failed and the migration
404-
needs to be aborted
435+
Returns
436+
-------
437+
bool
438+
True if the migration can proceed normally, False if a required solvability check failed and the migration
439+
needs to be aborted
405440
"""
406441
if not _is_solvability_check_needed(migrator, context, base_branch):
407442
return True
@@ -486,7 +521,7 @@ def run(
486521
base_branch: str = "main",
487522
**kwargs: typing.Any,
488523
) -> tuple[MigrationUidTypedDict, dict] | tuple[Literal[False], Literal[False]]:
489-
"""For a given feedstock and migration run the migration
524+
"""For a given feedstock and migration run the migration.
490525
491526
Parameters
492527
----------
@@ -510,7 +545,6 @@ def run(
510545
pr_json: dict
511546
The PR json object for recreating the PR as needed
512547
"""
513-
514548
# sometimes we get weird directory issues so make sure we reset
515549
os.chdir(BOT_HOME_DIR)
516550

@@ -1131,8 +1165,7 @@ def _setup_limits():
11311165

11321166

11331167
def _update_nodes_with_bot_rerun(gx: nx.DiGraph):
1134-
"""Go through all the open PRs and check if they are rerun"""
1135-
1168+
"""Go through all the open PRs and check if they are rerun."""
11361169
print("processing bot-rerun labels", flush=True)
11371170

11381171
for i, (name, node) in enumerate(gx.nodes.items()):
@@ -1194,8 +1227,7 @@ def _filter_ignored_versions(attrs, version):
11941227

11951228

11961229
def _update_nodes_with_new_versions(gx):
1197-
"""Updates every node with it's new version (when available)"""
1198-
1230+
"""Update every node with it's new version (when available)."""
11991231
print("updating nodes with new versions", flush=True)
12001232

12011233
version_nodes = get_all_keys_for_hashmap("versions")

conda_forge_tick/cf_tick_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"BotConfigVersionUpdates": {
2626
"additionalProperties": false,
27-
"description": "This dictates the behavior of the conda-forge auto-tick bot for version\nupdates",
27+
"description": "Dictates the behavior of the conda-forge auto-tick bot for version\nupdates.",
2828
"properties": {
2929
"random_fraction_to_keep": {
3030
"anyOf": [
@@ -106,7 +106,7 @@
106106
}
107107
},
108108
"additionalProperties": false,
109-
"description": "This dictates the behavior of the conda-forge auto-tick bot which issues\nautomatic version updates/migrations for feedstocks.\nA valid example is:\n\n```yaml\nbot:\n # can the bot automerge PRs it makes on this feedstock\n automerge: true\n # only automerge on successful version PRs, migrations are not automerged\n automerge: 'version'\n # only automerge on successful migration PRs, versions are not automerged\n automerge: 'migration'\n\n # only open PRs if resulting environment is solvable, useful for tightly coupled packages\n check_solvable: true\n\n # The bot.inspection key in the conda-forge.yml can have one of seven possible values and controls\n # the bots behaviour for automatic dependency updates:\n inspection: hint # generate hints using source code (backwards compatible)\n inspection: hint-all # generate hints using all methods\n inspection: hint-source # generate hints using only source code\n inspection: hint-grayskull # generate hints using only grayskull\n inspection: update-all # update recipe using all methods\n inspection: update-source # update recipe using only source code\n inspection: update-grayskull # update recipe using only grayskull\n inspection: disabled # don't update recipe, don't generate hints\n\n # any branches listed in this section will get bot migration PRs in addition\n # to the default branch\n abi_migration_branches:\n - 'v1.10.x'\n\n version_updates:\n # use this for packages that are updated too frequently\n random_fraction_to_keep: 0.1 # keeps 10% of versions at random\n exclude:\n - '08.14'\n```\n\nThe `abi_migration_branches` feature is useful to, for example, add a\nlong-term support (LTS) branch for a package.",
109+
"description": "Dictates the behavior of the conda-forge auto-tick bot which issues\nautomatic version updates/migrations for feedstocks.\n\nA valid example is:\n\n```yaml\nbot:\n # can the bot automerge PRs it makes on this feedstock\n automerge: true\n # only automerge on successful version PRs, migrations are not automerged\n automerge: 'version'\n # only automerge on successful migration PRs, versions are not automerged\n automerge: 'migration'\n\n # only open PRs if resulting environment is solvable, useful for tightly coupled packages\n check_solvable: true\n\n # The bot.inspection key in the conda-forge.yml can have one of seven possible values and controls\n # the bots behaviour for automatic dependency updates:\n inspection: hint # generate hints using source code (backwards compatible)\n inspection: hint-all # generate hints using all methods\n inspection: hint-source # generate hints using only source code\n inspection: hint-grayskull # generate hints using only grayskull\n inspection: update-all # update recipe using all methods\n inspection: update-source # update recipe using only source code\n inspection: update-grayskull # update recipe using only grayskull\n inspection: disabled # don't update recipe, don't generate hints\n\n # any branches listed in this section will get bot migration PRs in addition\n # to the default branch\n abi_migration_branches:\n - 'v1.10.x'\n\n version_updates:\n # use this for packages that are updated too frequently\n random_fraction_to_keep: 0.1 # keeps 10% of versions at random\n exclude:\n - '08.14'\n```\n\nThe `abi_migration_branches` feature is useful to, for example, add a\nlong-term support (LTS) branch for a package.",
110110
"properties": {
111111
"automerge": {
112112
"anyOf": [

conda_forge_tick/chaindb.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
2-
The code in this module is from xonsh (https://github.com/xonsh/xonsh/blob/main/xonsh/lib/collections.py)
3-
under the folloiwing license:
2+
The code in this module is from xonsh (https://github.com/xonsh/xonsh/blob/main/xonsh/lib/collections.py).
3+
4+
License:
45
56
Copyright 2015-2016, the xonsh developers. All rights reserved.
67
@@ -51,7 +52,8 @@ def __new__(cls):
5152

5253
class ChainDB(ChainMap):
5354
"""A ChainMap who's ``_getitem__`` returns either a ChainDB or
54-
the result. The results resolve to the outermost mapping."""
55+
the result. The results resolve to the outermost mapping.
56+
"""
5557

5658
def __getitem__(self, key):
5759
res = None

conda_forge_tick/cli.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ def make_import_to_package_mapping(
238238
ctx: CliContext,
239239
max_artifacts: int,
240240
) -> None:
241-
"""
242-
Make the import to package mapping.
243-
"""
241+
"""Make the import to package mapping."""
244242
from . import import_to_pkg
245243

246244
import_to_pkg.main(ctx, max_artifacts)
@@ -251,9 +249,7 @@ def make_import_to_package_mapping(
251249
def make_migrators(
252250
ctx: CliContext,
253251
) -> None:
254-
"""
255-
Make the migrators.
256-
"""
252+
"""Make the migrators."""
257253
from . import make_migrators as _make_migrators
258254

259255
_make_migrators.main(ctx)
@@ -281,9 +277,7 @@ def react_to_event(
281277
event: str,
282278
uid: str,
283279
) -> None:
284-
"""
285-
React to an event.
286-
"""
280+
"""React to an event."""
287281
from .events import react_to_event
288282

289283
react_to_event(ctx, event, uid)
@@ -292,9 +286,7 @@ def react_to_event(
292286
@main.command(name="clean-disk-space")
293287
@click.option("--ci-service", required=True, type=click.Choice(["github-actions"]))
294288
def clean_disk_space(ci_service) -> None:
295-
"""
296-
Clean up disk space on CI services.
297-
"""
289+
"""Clean up disk space on CI services."""
298290
from .os_utils import clean_disk_space
299291

300292
clean_disk_space(ci_service)

conda_forge_tick/config_schema.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class BotConfigVersionUpdatesSourcesChoice(StrEnum):
4747

4848
class BotConfigVersionUpdates(BaseModel):
4949
"""
50-
This dictates the behavior of the conda-forge auto-tick bot for version
51-
updates
50+
Dictates the behavior of the conda-forge auto-tick bot for version
51+
updates.
5252
"""
5353

5454
model_config: ConfigDict = ConfigDict(extra="forbid")
@@ -104,8 +104,9 @@ class BotConfigVersionUpdates(BaseModel):
104104

105105
class BotConfig(BaseModel):
106106
"""
107-
This dictates the behavior of the conda-forge auto-tick bot which issues
107+
Dictates the behavior of the conda-forge auto-tick bot which issues
108108
automatic version updates/migrations for feedstocks.
109+
109110
A valid example is:
110111
111112
```yaml

conda_forge_tick/container_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
"""This file runs specific tasks for the bot.
2+
"""Run specific tasks for the bot.
33
44
All imports from the bot need to be guarded by putting them in the subcommands.
55
This ensures that we can set important environment variables before any imports,
@@ -45,7 +45,7 @@
4545

4646
@contextmanager
4747
def _setenv(name, value):
48-
"""set an environment variable temporarily"""
48+
"""Set an environment variable temporarily."""
4949
old = os.environ.get(name)
5050
try:
5151
os.environ[name] = value

conda_forge_tick/contexts.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
@dataclass
2424
class MigratorSessionContext:
25-
"""Singleton session context. There should generally only be one of these"""
25+
"""Singleton session context. There should generally only be one of these."""
2626

2727
graph: DiGraph = None
2828
smithy_version: str = ""
@@ -56,9 +56,7 @@ def git_repo_name(self) -> str:
5656

5757
@property
5858
def git_http_ref(self) -> str:
59-
"""
60-
A link to the feedstock's GitHub repository.
61-
"""
59+
"""A link to the feedstock's GitHub repository."""
6260
return f"https://github.com/{self.git_repo_owner}/{self.git_repo_name}"
6361

6462
@property

conda_forge_tick/depfinder_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def simple_import_to_pkg_map(
123123
ignore=None,
124124
custom_namespaces=None,
125125
):
126-
"""Provide the map between all the imports and their possible packages
126+
"""Provide the map between all the imports and their possible packages.
127127
128128
Parameters
129129
----------

conda_forge_tick/deploy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def _get_files_to_delete():
186186

187187

188188
def _get_pth_commit_message(pth):
189-
"""make a nice message for stuff managed via LazyJson."""
189+
"""Make a nice message for stuff managed via LazyJson."""
190190
step_name = os.environ.get("GITHUB_WORKFLOW", "update graph")
191191
msg_pth = pth
192192
parts = pth.split("/")
@@ -204,7 +204,7 @@ def _reset_and_restore_file(pth):
204204

205205

206206
def deploy(ctx: CliContext, dirs_to_deploy: list[str] = None):
207-
"""Deploy the graph to GitHub"""
207+
"""Deploy the graph to GitHub."""
208208
if ctx.dry_run:
209209
print("(dry run) deploying")
210210
return

conda_forge_tick/env_management.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self):
1414
self.classified_info = {}
1515

1616
def hide_env_vars(self):
17-
"""Remove sensitive env vars"""
17+
"""Remove sensitive env vars."""
1818
self.classified_info.update(
1919
{
2020
k: os.environ.pop(k, self.classified_info.get(k, None))
@@ -23,15 +23,16 @@ def hide_env_vars(self):
2323
)
2424

2525
def reveal_env_vars(self):
26-
"""Restore sensitive env vars"""
26+
"""Restore sensitive env vars."""
2727
os.environ.update(
2828
**{k: v for k, v in self.classified_info.items() if v is not None}
2929
)
3030

3131
@contextmanager
3232
def sensitive_env(self):
3333
"""Add sensitive keys to environ if needed, when ctx is finished remove keys and update the sensitive env
34-
in case any were updated inside the ctx"""
34+
in case any were updated inside the ctx.
35+
"""
3536
self.reveal_env_vars()
3637
yield os.environ
3738
self.hide_env_vars()

0 commit comments

Comments
 (0)