Skip to content

Conversation

@nathanjmcdougall
Copy link
Contributor

Continuing from #282 and #284

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 19, 2025

CodSpeed Performance Report

Merging #290 will not alter performance

Comparing nathanjmcdougall:refactor/enable-strict-ruff-config (2681042) with main (7fc49c4)

Summary

✅ 26 untouched
⏩ 23 skipped1

Footnotes

  1. 23 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Collaborator

@seddonym seddonym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, it's great.

I would slightly prefer some of the rules to be turned off, let's align in the comment threads. It should be obvious from my tone on each one how strongly I feel (generally, not very!)

# While we would expect the module to be in here,
# there's no point in crashing if, for some reason, it's not.
raise CacheMiss
raise CacheMiss from None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

from ..application.ports.caching import CacheMiss
from grimp import _rustgrimp as rust # type: ignore[attr-defined]

if TYPE_CHECKING:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the fence on this one - I suppose there is hypothetically a slight runtime penalty, but for me it makes the code a little less readable. What rule is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TC ruleset from flake8-type-checking, specifically codes TC001, TC002, and TC003.

https://docs.astral.sh/ruff/rules/#flake8-type-checking-tc

The runtime penalty is probably near-zero because import grimp will basically import all submodules, and grimp has no dependencies. So it would only be stdlib imports but I think it's not worth being concerned about those.

I've gone ahead and reverted this from the PR. We can always add it back in later if there's a desire for it, it's easy to migrate with autofix.

)
except rust.NoSuchContainer as e:
raise NoSuchContainer(str(e))
raise NoSuchContainer(str(e)) from None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be from e no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd be in a better position to know :)
Probably I should have put that rule in a separate PR for closer review.

Makes sense, I think basically I thought since the str(e) was getting passed to the error that perhaps duplicating it in the traceback could be excessive especially since we'll hit the rust layer pretty soon after

Anyway I've made it from exc (consistent naming with other parts of the codebase).

def __getattr__(name: str) -> Any:
if name == "NamespacePackageEncountered":
_NamespacePackageEncountered._warn_deprecated()
warnings.warn(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just note, that Ruff agreed with your intuition in #276 so I've actually refactored it after all :)

https://docs.astral.sh/ruff/rules/private-member-access/

Copy link
Collaborator

@seddonym seddonym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely stuff, thanks for taking the trouble to do this.

@@ -0,0 +1,58 @@
line-length = 99
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going the extra mile with all these comments! 👏🏻

I may edit some of them in a subsequent PR as I don't agree with everything here but it's a really useful first cut.

@seddonym seddonym merged commit ea65558 into python-grimp:main Dec 22, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants