Comments (5)
Yep, that helps! Seeing a considerable improvement now. Thanks for that!
Will look to get the changes PRed up.
from pylint.
Thanks for the report! Sounds reasonable to expect ignored-modules
to be more useful than it is.
I'm showing this is solved with two tiny patches to pylint and astroid. If you're up for it, would you be willing to confirm and open the PRs? We'd need just a little test and some documentation spruce-ups for the ignored-modules option.
diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py
index 30250154e..473cd0900 100644
--- a/pylint/lint/pylinter.py
+++ b/pylint/lint/pylinter.py
@@ -1073,6 +1073,7 @@ class PyLinter(
MANAGER.always_load_extensions = self.config.unsafe_load_any_extension
MANAGER.max_inferable_values = self.config.limit_inference_results
MANAGER.extension_package_whitelist.update(self.config.extension_pkg_allow_list)
+ MANAGER.module_denylist.extend(self.config.ignored_modules)
if self.config.extension_pkg_whitelist:
MANAGER.extension_package_whitelist.update(
self.config.extension_pkg_whitelist
diff --git a/astroid/manager.py b/astroid/manager.py
index c499fe55..386a3838 100644
--- a/astroid/manager.py
+++ b/astroid/manager.py
@@ -59,6 +59,7 @@ class AstroidManager:
"optimize_ast": False,
"max_inferable_values": 100,
"extension_package_whitelist": set(),
+ "module_denylist": [],
"_transform": TransformVisitor(),
}
@@ -70,6 +71,7 @@ class AstroidManager:
self.extension_package_whitelist = AstroidManager.brain[
"extension_package_whitelist"
]
+ self.module_denylist = AstroidManager.brain["module_denylist"]
self._transform = AstroidManager.brain["_transform"]
@property
@@ -200,6 +203,8 @@ class AstroidManager:
# importing a module with the same name as the file that is importing
# we want to fallback on the import system to make sure we get the correct
# module.
+ if modname in self.module_denylist:
+ raise AstroidImportError("Skipping")
if modname in self.astroid_cache and use_cache:
return self.astroid_cache[modname]
if modname == "__main__":
from pylint.
Aha ok. I incorrectly assumed ignored-modules did that already.
I checked out the pylint and astroid repos, made those changes locally and ran some benchmarks on my codebase with (this time using all cores to get answers faster).
From what I'm seeing, those changes make no effect to the speed or memory usage when adding --ignored-modules=azure
. I'm not quite sure why as adding some debug around the modified code, we are hitting the raise AstroidImportError("Skipping")
line with the azure
module.
Any pointers?
from pylint.
Make sure you're using the full module name, e.g. azure.mgmt.network.v2022_07_01.models
from pylint.
Wonderful. Feel free to make improvements (e.g. for consistency, that collection should probably be a set...)
from pylint.
Related Issues (20)
- False positive for E0601 when variable first assigned in assignment expression in `if` clause of a comprehension
- False positive with return guard
- Example of using pylint as a pre-commit hook does not mention use of spelling extra HOT 1
- Crash AstroidError - AttributeError: 'TreeRebuilder' object has no attribute 'visit_typealias' HOT 4
- Crash 💥 `RecursionError` when upgrading from 3.0.3 to 3.1.0 HOT 2
- False positive on E1101: no-member when using "random.choices"
- Suggest flattening nested idempotent function applications HOT 3
- False positive singleton-comparison with sqlalchemy's filter
- Pylint crash: RecursionError: maximum recursion depth exceeded HOT 2
- Incorrect "Value '<val>' is unsubscriptable" with class method type overloading HOT 2
- sdist is missing requirements files
- 3.1.0: Nine test_functional and one test_package fails HOT 4
- Crashed while using pylint as a static test for a docker
- False positive assignment-from-no-return on generator with nested yield expression
- [Documentation] - Fix 2 typos in `too-many-branches` documentation
- spelling of Sphinx parameter descriptions
- Unexpected keyword argument for Generic dataclass with ABC bounded TypeVar
- Pylint 3.1.0 reports ByteString as deprecated class when ``py-version = 3.8`` HOT 3
- Cannot disable 'cyclic-import' warning HOT 1
- False-positive E0:601 on `datetime` when USE_TYPECHECKING HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylint.