Repository navigation
Conversation
Fix the remaining violations by hand (PYI036, RUF012, TC004, SIM117, SIM115, PIE790) and ignore BLE001, S110, TRY002 and TRY004, which flag code that is deliberate or whose fix changes the exception type users see. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
hirosassa
requested review from
hiro-o918,
kitagry,
mamo3gr,
mski-iksm and
ujiuji1259
as code owners
November 23, 2026 20:52
kitagry
approved these changes
Nov 25, 2026
kitagry
left a comment
Member
There was a problem hiding this comment.
Thanks! This matches what we agreed on in #698, and I checked it locally on top of #705 (ruff 0.17.5):
ruff check .passes with the default rules, andruff format --check, pyright (0 errors) andpytest -n auto(873 passed) pass too.- The
ignorelist has exactly the four rules from the thread, with WHY comments, andextend-select(B, I, UP, TID253), B006/B008 and the per-file-ignores are unchanged. No new# noqa. - TC004: with
from luigi.contrib.s3 import S3Client/from luigi.contrib.gcs import GCSClientinside the functions, the optional dependencies stay lazy. In a clean venv with onlypip install .(nos3/gcsextras),import gokart,gokart.s3_configandgokart.gcs_configwork on Python 3.11 and 3.14, none of boto3 / google.cloud.storage / googleapiclient / luigi.contrib.s3 / luigi.contrib.gcs is loaded, andS3Config().get_s3_client()still raises the friendly "Install them with: pip install gokart[s3]" error. The tests that patchluigi.contrib.gcs.GCSClientstill work because the name is looked up when the function runs. - The
__exit__annotations (type[BaseException] | None,BaseException | None,TracebackType | None) are the standard ones, and__enter__already returnsSelfafter #705. - Nothing from #700 is repeated: the
ObjectStorageandTaskLockExceptionfixes are already in the base, and this PR does not touch them.
Two nits, both non-blocking:
test/test_build.py:333:resources: ClassVar[...] # pyright: ignore[reportIncompatibleVariableOverride]silences RUF012 by adding a pyright ignore, because luigi declaresresourcesas an instance variable (resources: Dict[str, Any] = {}). Overridingprocess_resources()(which the worker calls; seegokart/worker.py:967) avoids both theClassVarand the ignore:
class _NeedsUnavailableResource(gokart.TaskOnKart[int]):
task_namespace = __name__
# WHY: luigi treats an unconfigured resource as having 1 unit, so asking for 2 is never satisfiable; the odd name keeps a developer's luigi.cfg out of it
def process_resources(self) -> dict[str, int]:
return {'_gokart_test_not_run': 2}I tried it: ruff, pyright and the test pass. A plain resources = {...} # noqa: RUF012 would also work. Fine to leave as is if you prefer.
gokart/worker.py:592(andWorkerProtocol.__exit__ingokart/build.py:91):exc_type/exc_valuewere renamed, but the third parameter is stilltraceback, which shadows theimport tracebackat the top ofworker.py(used at lines 453, 461, 676). It is harmless today, but since the signature is being touched anyway,exc_tbwould keep someone from callingtraceback.format_exc()there later by mistake.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #698 (step 3 of the plan in the thread). Stacked on #705.
What
Follows ruff's default rule set (option 1 in #698): drops the
select = ["E4", "E7", "E9", "F"]pin added in #693.PYI036:__exit__annotations (build.py,worker.py).RUF012:ClassVarfor_instances,forward_reporter_attributesand a test task'sresources.TC004: importGCSClient/S3Clientby name instead of the module, so the optional dependencies stay lazily imported (a false positive of the rule, as noted in the thread).SIM117: merged nestedwithin tests.SIM115: theopen()lambdas intest_target.pybecame helpers that usewith.PIE790: unnecessarypass.ignorelist with a WHY comment:BLE001,S110(the worker and the file processors catch everything on purpose),TRY002,TRY004(fixing them changes the exception type users see, which belongs to 2.0.0 / 2.0.0 removals #685).Verification
ruff check, ruff format, pyright (0 errors) and the full pytest suite (873 passed) pass locally.
🤖 Generated with Claude Code