pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.26k stars 1.12k forks source link

Move typechecking imports under TYPE_CHECKING flag #9970

Open nickdrozd opened 4 days ago

nickdrozd commented 4 days ago

Type of Changes

Type
:hammer: Refactoring

Description

Putting https://github.com/pylint-dev/pylint/pull/9964 to the test. Move typechecking imports behind TYPE_CHECKING. Also move a few type aliases. The idea is to move out anything that isn't used at runtime.

Similar to https://github.com/pylint-dev/astroid/pull/2585

nickdrozd commented 4 days ago

However, it does impose a greater workload on developers and us maintainer. If we change something, we constantly need to make sure to double check all imports or run the risk of something failing.

I don't understand what you mean. There is the minor one-time cost of reviewing this PR (and the other one). What other workload is there?

nickdrozd commented 4 days ago

https://github.com/pylint-dev/pylint/issues/8893 presents a problem for this kind of change.

codecov[bot] commented 4 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.76%. Comparing base (88e4bc6) to head (8d455ab). Report is 1 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970/graphs/tree.svg?width=650&height=150&src=pr&token=ZETEzayrfk&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev)](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev) ```diff @@ Coverage Diff @@ ## main #9970 +/- ## ========================================== - Coverage 95.80% 95.76% -0.05% ========================================== Files 174 174 Lines 18940 18750 -190 ========================================== - Hits 18146 17956 -190 Misses 794 794 ``` | [Files with missing lines](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev) | Coverage Δ | | |---|---|---| | [pylint/checkers/bad\_chained\_comparison.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fbad_chained_comparison.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2JhZF9jaGFpbmVkX2NvbXBhcmlzb24ucHk=) | `100.00% <ø> (ø)` | | | [pylint/checkers/base/basic\_checker.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fbase%2Fbasic_checker.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2Jhc2UvYmFzaWNfY2hlY2tlci5weQ==) | `98.07% <100.00%> (-0.01%)` | :arrow_down: | | [pylint/checkers/base/basic\_error\_checker.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fbase%2Fbasic_error_checker.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2Jhc2UvYmFzaWNfZXJyb3JfY2hlY2tlci5weQ==) | `95.43% <100.00%> (ø)` | | | [pylint/checkers/base/docstring\_checker.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fbase%2Fdocstring_checker.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2Jhc2UvZG9jc3RyaW5nX2NoZWNrZXIucHk=) | `97.64% <100.00%> (ø)` | | | [pylint/checkers/base/name\_checker/checker.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fbase%2Fname_checker%2Fchecker.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2Jhc2UvbmFtZV9jaGVja2VyL2NoZWNrZXIucHk=) | `98.62% <ø> (-0.02%)` | :arrow_down: | | [pylint/checkers/base/name\_checker/naming\_style.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fbase%2Fname_checker%2Fnaming_style.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2Jhc2UvbmFtZV9jaGVja2VyL25hbWluZ19zdHlsZS5weQ==) | `100.00% <100.00%> (ø)` | | | [pylint/checkers/base\_checker.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fbase_checker.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2Jhc2VfY2hlY2tlci5weQ==) | `94.87% <100.00%> (-0.17%)` | :arrow_down: | | [pylint/checkers/classes/class\_checker.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fclasses%2Fclass_checker.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2NsYXNzZXMvY2xhc3NfY2hlY2tlci5weQ==) | `93.71% <100.00%> (-0.04%)` | :arrow_down: | | [pylint/checkers/classes/special\_methods\_checker.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fclasses%2Fspecial_methods_checker.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2NsYXNzZXMvc3BlY2lhbF9tZXRob2RzX2NoZWNrZXIucHk=) | `95.37% <100.00%> (-0.08%)` | :arrow_down: | | [pylint/checkers/deprecated.py](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree&filepath=pylint%2Fcheckers%2Fdeprecated.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev#diff-cHlsaW50L2NoZWNrZXJzL2RlcHJlY2F0ZWQucHk=) | `99.03% <100.00%> (-0.01%)` | :arrow_down: | | ... and [92 more](https://app.codecov.io/gh/pylint-dev/pylint/pull/9970?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pylint-dev) | |
github-actions[bot] commented 4 days ago

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 8d455abd0617a2666560bf3ed0c062cacc9654d4