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

pylint doesn't continue searching for files under a directory that is not a package #9764

Closed
ocelotl opened this issue Jul 2, 2024 · 2 comments · Fixed by #9768 or #9940
Closed

pylint doesn't continue searching for files under a directory that is not a package #9764

ocelotl opened this issue Jul 2, 2024 · 2 comments · Fixed by #9768 or #9940
Assignees
Labels
Bug 🪲 namespace-package Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@ocelotl
Copy link

ocelotl commented Jul 2, 2024

Bug description

This bug is happening when running pylint in this repo at this commit.

I noticed different behaviors when running cd propagator; pylint opentelemetry-propagator-b3 and when running pylint propagator/opentelemetry-propagator-b3.

I found this issue while working on this other issue.

Configuration

The pylint configuration is here.

Command used

I cloned that repo, and run tox -e lint first to create the lint virtual environment. Then I activated the lint virtual environment: source .tox/lint/bin/activate.

I ran pylint propagator/opentelemetry-propagator-b3.

Then I ran cd propagator and then I ran pylint opentelemetry-propagator-b3.

Pylint output

When I ran pylint propagator/opentelemetry-propagator-b3 I got this output:

(lint) tigre@hilleman:~/github/ocelotl/opentelemetry-python$ pylint propagator/opentelemetry-propagator-b3
************* Module opentelemetry-propagator-b3
propagator/opentelemetry-propagator-b3/__init__.py:1:0: F0010: error while code parsing: Unable to load file propagator/opentelemetry-propagator-b3/__init__.py:
[Errno 2] No such file or directory: 'propagator/opentelemetry-propagator-b3/__init__.py' (parse-error)

When I ran cd propagator and then I ran pylint opentelemetry-propagator-b3 I got this output:

************* Module tests.test_b3_format
opentelemetry-propagator-b3/tests/test_b3_format.py:124:0: C0301: Line too long (101/100) (line-too-long)
opentelemetry-propagator-b3/tests/test_b3_format.py:141:0: C0301: Line too long (103/100) (line-too-long)
opentelemetry-propagator-b3/tests/test_b3_format.py:1:0: C0114: Missing module docstring (missing-module-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:31:0: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:36:13: W0212: Access to a protected member _Span of a client class (protected-access)
opentelemetry-propagator-b3/tests/test_b3_format.py:37:12: W0212: Access to a protected member _Span of a client class (protected-access)
opentelemetry-propagator-b3/tests/test_b3_format.py:56:0: C0115: Missing class docstring (missing-class-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:60:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:69:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:78:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:83:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:88:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:91:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:94:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:284:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:304:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:328:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:353:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:377:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:396:4: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:409:8: C0115: Missing class docstring (missing-class-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:425:8: E1129: Context manager 'generator' doesn't implement __enter__ and __exit__. (not-context-manager)
opentelemetry-propagator-b3/tests/test_b3_format.py:426:12: E1129: Context manager 'generator' doesn't implement __enter__ and __exit__. (not-context-manager)
opentelemetry-propagator-b3/tests/test_b3_format.py:445:0: C0115: Missing class docstring (missing-class-docstring)
opentelemetry-propagator-b3/tests/test_b3_format.py:461:0: C0115: Missing class docstring (missing-class-docstring)
************* Module tests.performance.benchmarks.trace.propagation.test_benchmark_b3_format
opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py:1:0: C0114: Missing module docstring (missing-module-docstring)
opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py:16:0: R0402: Use 'from opentelemetry.sdk import trace' instead (consider-using-from-import)
opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py:21:0: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py:30:0: C0116: Missing function or method docstring (missing-function-docstring)
opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py:32:4: E1129: Context manager 'generator' doesn't implement __enter__ and __exit__. (not-context-manager)
opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py:33:8: E1129: Context manager 'generator' doesn't implement __enter__ and __exit__. (not-context-manager)
************* Module src.opentelemetry.propagators.b3
opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/__init__.py:196:0: C0115: Missing class docstring (missing-class-docstring)
************* Module src.opentelemetry.propagators.b3.version
opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/version.py:1:0: C0114: Missing module docstring (missing-module-docstring)

------------------------------------------------------------------
Your code has been rated at 8.32/10 (previous run: 8.32/10, +0.00)

Expected behavior

I expected the behavior would be the one that happens when I run cd propagator and then I run pylint opentelemetry-propagator-b3 in both cases.

Pylint version

(lint) tigre@hilleman:~/github/ocelotl/opentelemetry-python/propagator$ pylint --version
pylint 3.0.2
astroid 3.0.3
Python 3.11.2 (main, Feb 12 2023, 12:17:23) [GCC 11.3.0]

OS / Environment

(lint) tigre@hilleman:~/github/ocelotl/opentelemetry-python/propagator$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

Additional dependencies

alabaster==0.7.16
asgiref==3.7.2
astroid==3.0.3
Babel==2.15.0
black==24.3.0
bleach==4.1.0
cachetools==5.3.3
certifi==2024.2.2
cfgv==3.4.0
charset-normalizer==3.3.2
click==8.1.7
codespell==2.1.0
coverage==7.5.4
Deprecated==1.2.14
dill==0.3.8
distlib==0.3.8
docutils==0.20.1
filelock==3.15.4
flake8==6.1.0
flaky==3.7.0
gitdb==4.0.11
GitPython==3.1.41
google-api-core==2.17.1
google-auth==2.28.1
googleapis-common-protos==1.62.0
grpcio==1.62.0
httpretty==1.1.4
identify==2.5.36
idna==3.7
imagesize==1.4.1
importlib-metadata==6.11.0
iniconfig==2.0.0
isort==5.12.0
Jinja2==3.1.4
MarkupSafe==2.1.3
mccabe==0.7.0
mypy==1.9.0
mypy-extensions==1.0.0
nh3==0.2.17
nodeenv==1.9.1
opencensus==0.11.1
opencensus-context==0.1.3
opencensus-proto==0.1.0
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_api&subdirectory=opentelemetry-api
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_opencensus&subdirectory=exporter/opentelemetry-exporter-opencensus
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_otlp&subdirectory=exporter/opentelemetry-exporter-otlp
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_otlp_proto_common&subdirectory=exporter/opentelemetry-exporter-otlp-proto-common
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_otlp_proto_grpc&subdirectory=exporter/opentelemetry-exporter-otlp-proto-grpc
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_otlp_proto_http&subdirectory=exporter/opentelemetry-exporter-otlp-proto-http
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_prometheus&subdirectory=exporter/opentelemetry-exporter-prometheus
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_zipkin&subdirectory=exporter/opentelemetry-exporter-zipkin
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_zipkin_json&subdirectory=exporter/opentelemetry-exporter-zipkin-json
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_exporter_zipkin_proto_http&subdirectory=exporter/opentelemetry-exporter-zipkin-proto-http
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_opencensus_shim&subdirectory=shim/opentelemetry-opencensus-shim
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_opentracing_shim&subdirectory=shim/opentelemetry-opentracing-shim
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_propagator_b3&subdirectory=propagator/opentelemetry-propagator-b3
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_propagator_jaeger&subdirectory=propagator/opentelemetry-propagator-jaeger
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_proto&subdirectory=opentelemetry-proto
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_sdk&subdirectory=opentelemetry-sdk
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_semantic_conventions&subdirectory=opentelemetry-semantic-conventions
-e git+ssh://git@github.com/ocelotl/opentelemetry-python.git@507f769e9616bea2329544417303d5160e00a65e#egg=opentelemetry_test_utils&subdirectory=tests/opentelemetry-test-utils
opentracing==2.4.0
packaging==24.0
pathspec==0.12.1
platformdirs==4.2.2
pluggy==1.5.0
pre-commit==3.7.0
prometheus_client==0.20.0
protobuf==3.20.3
psutil==5.9.6
py-cpuinfo==9.0.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycodestyle==2.11.1
pyflakes==3.1.0
Pygments==2.18.0
pylint==3.0.2
pytest==7.4.4
pytest-benchmark==4.0.0
pytest-cov==4.1.0
PyYAML==6.0.1
readme-renderer==42.0
requests==2.32.3
responses==0.24.1
rsa==4.9
ruamel.yaml==0.17.21
six==1.16.0
smmap==5.0.1
snowballstemmer==2.2.0
Sphinx==7.1.2
sphinx-autodoc-typehints==1.25.2
sphinx-rtd-theme==2.0.0rc4
sphinxcontrib-applehelp==1.0.8
sphinxcontrib-devhelp==1.0.6
sphinxcontrib-htmlhelp==2.0.5
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.7
sphinxcontrib-serializinghtml==1.1.10
tomli==2.0.1
tomlkit==0.12.5
typing_extensions==4.10.0
urllib3==2.2.2
virtualenv==20.26.3
webencodings==0.5.1
wrapt==1.16.0
zipp==3.17.0
@ocelotl ocelotl added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jul 2, 2024
@ocelotl
Copy link
Author

ocelotl commented Jul 2, 2024

open-telemetry/opentelemetry-python#3814 to link these 2 issues.

@jacobtylerwalls jacobtylerwalls changed the title Path of the checked directory affects pylint results pylint doesn't continue searching for files under a directory that is not a package Jul 4, 2024
@jacobtylerwalls
Copy link
Member

Thanks for the report, I'm showing this is fixed with:

diff --git a/pylint/lint/expand_modules.py b/pylint/lint/expand_modules.py
index 04e701884..f40bdeea5 100644
--- a/pylint/lint/expand_modules.py
+++ b/pylint/lint/expand_modules.py
@@ -122,7 +122,7 @@ def expand_modules(
             )
         except ImportError:
             # Might not be acceptable, don't crash.
-            is_namespace = False
+            is_namespace = not os.path.exists(filepath)
             is_directory = os.path.isdir(something)
         else:
             is_namespace = modutils.is_namespace(spec)

Needs confirmation and a regression test.

@jacobtylerwalls jacobtylerwalls added namespace-package Needs PR This issue is accepted, sufficiently specified and now needs an implementation Bug 🪲 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jul 4, 2024
@jacobtylerwalls jacobtylerwalls self-assigned this Jul 4, 2024
@jacobtylerwalls jacobtylerwalls added this to the 3.3.0 milestone Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 namespace-package Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
2 participants