Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(custom-checks): add check to prevent circular imports #887

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

glevco
Copy link
Contributor

@glevco glevco commented Dec 6, 2023

Motivation

Sometimes, when something is imported from the hathor module in an entrypoint file (from CLI commands), a circular import could happen, causing the full node node startup to fail. This has happened a couple times in the past (example).

This problem would not be caught by our linters and neither tests, so it would only appear after the merge to master, when the docker image is generated. This PR aims to prevent this by adding a custom lint check that prohibits importing from hathor in the module-level of CLI entrypoints. For specific cases, a # no-custom-check comment can be added to opt-out of this check. Here's an example of a failing output.

This will also be useful in #889, as it prevents indirect calls that could automatically install the default Twisted Reactor before our code had a chance to customize it.

Acceptance Criteria

  • Add new custom check to prevent importing from the hathor module in the module-level of CLI related files.
  • Update code to conform with the new check.

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@glevco glevco self-assigned this Dec 6, 2023
@glevco glevco force-pushed the chore/circular-imports-check branch 2 times, most recently from 9bb764e to 9c984aa Compare December 6, 2023 23:06
Copy link

codecov bot commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7dded42) 85.33% compared to head (de67a6b) 85.37%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #887      +/-   ##
==========================================
+ Coverage   85.33%   85.37%   +0.04%     
==========================================
  Files         282      282              
  Lines       22280    22280              
  Branches     3366     3366              
==========================================
+ Hits        19012    19021       +9     
+ Misses       2596     2588       -8     
+ Partials      672      671       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glevco glevco marked this pull request as ready for review December 7, 2023 16:25
extras/custom_checks.sh Outdated Show resolved Hide resolved
extras/custom_checks.sh Show resolved Hide resolved
extras/custom_checks.sh Show resolved Hide resolved
@glevco glevco force-pushed the chore/circular-imports-check branch from 1ac0f09 to 03d6758 Compare December 18, 2023 18:21
@glevco glevco force-pushed the chore/circular-imports-check branch from 03d6758 to de67a6b Compare December 18, 2023 19:57
@glevco glevco merged commit 27381c1 into master Dec 18, 2023
9 checks passed
@glevco glevco deleted the chore/circular-imports-check branch December 18, 2023 21:23
This was referenced Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants