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 is not actually checking some test files #3814

Open
aabmass opened this issue Mar 28, 2024 · 11 comments · May be fixed by #4048
Open

Pylint is not actually checking some test files #3814

aabmass opened this issue Mar 28, 2024 · 11 comments · May be fixed by #4048
Labels
bug Something isn't working build & infra Issues related to build & infrastructure.

Comments

@aabmass
Copy link
Member

aabmass commented Mar 28, 2024

I realized today that possibly large swaths of the codebase are not being checked by pylint. It seems like it is not recursing into directories that don't have an __init__.py (namespace packages) AND aren't in sys.path/PYTHONPATH. tox -e lint installs the packages (not tests) into it's venv and then runs python scripts/eachdist.py lint --check-only which in turn runs pylint on directory roots tests/ and src/opentelemetry dirs:

pylint opentelemetry-api/tests \
  opentelemetry-api/src/opentelemetry 
  # ...

If I invoke this command in the venv with the tests directory:

$ pylint opentelemetry-api/tests

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

If I invoke on a specific file in a dir without an __init__.py:

$ pylint opentelemetry-api/tests/attributes/test_attributes.py 
************* Module test_attributes
opentelemetry-api/tests/attributes/test_attributes.py:24:4: C0103: Method name "assertValid" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]*|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern) (invalid-name)
opentelemetry-api/tests/attributes/test_attributes.py:30:4: C0103: Method name "assertInvalid" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]*|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern) (invalid-name)
opentelemetry-api/tests/attributes/test_attributes.py:114:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:133:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:139:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:151:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:161:8: C0206: Consider iterating with .items() (consider-using-dict-items)

-----------------------------------
Your code has been rated at 9.31/1
@aabmass aabmass added bug Something isn't working build & infra Issues related to build & infrastructure. labels Mar 28, 2024
@aabmass
Copy link
Member Author

aabmass commented Mar 28, 2024

With some scripting and modifying pylint to print out files analyzed following this SO, I think there are 51 files not being linted:

Show files

opentelemetry-api/tests/attributes/test_attributes.py
opentelemetry-api/tests/baggage/propagation/test_propagation.py
opentelemetry-api/tests/baggage/test_baggage.py
opentelemetry-api/tests/logs/test_logger_provider.py
opentelemetry-api/tests/logs/test_log_record.py
opentelemetry-api/tests/logs/test_proxy.py
opentelemetry-api/tests/metrics/test_instruments.py
opentelemetry-api/tests/metrics/test_meter_provider.py
opentelemetry-api/tests/metrics/test_meter.py
opentelemetry-api/tests/metrics/test_observation.py
opentelemetry-api/tests/propagators/test_composite.py
opentelemetry-api/tests/propagators/test_global_httptextformat.py
opentelemetry-api/tests/propagators/test_propagators.py
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py
opentelemetry-api/tests/trace/propagation/test_textmap.py
opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py
opentelemetry-api/tests/util/test_contextmanager.py
opentelemetry-api/tests/util/test__importlib_metadata.py
opentelemetry-api/tests/util/test_once.py
opentelemetry-api/tests/util/test__providers.py
opentelemetry-api/tests/util/test_re.py
opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py
opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponent_mapping.py
opentelemetry-sdk/tests/metrics/exponential_histogram/test_logarithm_mapping.py
opentelemetry-sdk/tests/metrics/integration_test/test_console_exporter.py
opentelemetry-sdk/tests/metrics/integration_test/test_cpu_time.py
opentelemetry-sdk/tests/metrics/integration_test/test_disable_default_views.py
opentelemetry-sdk/tests/metrics/integration_test/test_explicit_bucket_histogram_aggregation.py
opentelemetry-sdk/tests/metrics/integration_test/test_exporter_concurrency.py
opentelemetry-sdk/tests/metrics/integration_test/test_histogram_export.py
opentelemetry-sdk/tests/metrics/integration_test/test_sum_aggregation.py
opentelemetry-sdk/tests/metrics/integration_test/test_time_align.py
opentelemetry-sdk/tests/metrics/test_aggregation.py
opentelemetry-sdk/tests/metrics/test_backward_compat.py
opentelemetry-sdk/tests/metrics/test_import.py
opentelemetry-sdk/tests/metrics/test_in_memory_metric_reader.py
opentelemetry-sdk/tests/metrics/test_instrument.py
opentelemetry-sdk/tests/metrics/test_measurement_consumer.py
opentelemetry-sdk/tests/metrics/test_metric_reader.py
opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py
opentelemetry-sdk/tests/metrics/test_metrics.py
opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py
opentelemetry-sdk/tests/metrics/test_point.py
opentelemetry-sdk/tests/metrics/test_view_instrument_match.py
opentelemetry-sdk/tests/metrics/test_view.py
opentelemetry-sdk/tests/performance/benchmarks/metrics/test_benchmark_metrics_histogram,.py
opentelemetry-sdk/tests/performance/benchmarks/metrics/test_benchmark_metrics.py
opentelemetry-sdk/tests/performance/benchmarks/trace/test_benchmark_trace.py
opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_batch_export.py
opentelemetry-sdk/tests/performance/resource-usage/trace/profile_resource_usage_simple_export.py
propagator/opentelemetry-propagator-b3/tests/performance/benchmarks/trace/propagation/test_benchmark_b3_format.py

These are all within test directories that don't have an __init__.py file.

@aabmass aabmass changed the title Pylint is not actually checking some files Pylint is not actually checking some test files Mar 28, 2024
This was referenced Mar 28, 2024
@xrmx
Copy link
Contributor

xrmx commented Mar 29, 2024

From a quick glance may not be the most useful warnings to be honest. Is ruff finding them?

@aabmass
Copy link
Member Author

aabmass commented Mar 29, 2024

I think ruff recursively finds all files in the filesystem so would be checking them. It doesn't try to do fancy inference so doesn't need to be aware of the module path for the files afaict. Pylint seems to rely on the presence of __init__.py in a directory OR the files being in sys.path but I'm not sure. There is a --recursive=y option that actually seems to break everything:

$ pylint opentelemetry-api/src/opentelemetry/                    
                                                                                                                                             
--------------------------------------------------------------------                                                                         
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

$ pylint --recursive=y opentelemetry-api/src/opentelemetry/      
************* Module opentelemetry.baggage
opentelemetry-api/src/opentelemetry/baggage/__init__.py:17:0: E0611: No name 'MappingProxyType' in module 'types' (no-name-in-module)
************* Module opentelemetry.trace.span
opentelemetry-api/src/opentelemetry/trace/span.py:190:32: E1101: Module 'types' has no 'TracebackType' member (no-member)
************* Module opentelemetry.trace.propagation.tracecontext
opentelemetry-api/src/opentelemetry/trace/propagation/tracecontext.py:54:16: E1101: Module 're' has no 'search' member (no-member)

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

I think what's happening is pylint is using the types and re modules in opentelemetry-api/src/opentelemetry/util/ instead of stdlib. Not sure 🙃

The worst part is that --recursive=y still doesn't fix the discovery of test files. Basically pylint's file discovery seems to be really buggy. I think invoking it explicitly with paths to python files is the safest workaround.

@aabmass
Copy link
Member Author

aabmass commented Mar 29, 2024

Maybe this is the culprit pylint-dev/pylint#3944

EDIT yup that actually fixes it. I tried deleting __init__.py files and pylint correctly discovers the test files.

@xrmx
Copy link
Contributor

xrmx commented Mar 29, 2024

@aabmass If ruff is fine then we will be fine once we start using it no? I won't bother with missing pylint warning in tests.

@xrmx xrmx added good first issue Good first issue and removed good first issue Good first issue labels Jul 2, 2024
@ocelotl
Copy link
Contributor

ocelotl commented Jul 2, 2024

Maybe this is the culprit pylint-dev/pylint#3944

EDIT yup that actually fixes it. I tried deleting __init__.py files and pylint correctly discovers the test files.

Do you actually mean

EDIT yup that actually fixes it. I tried adding __init__.py files and pylint correctly discovers the test files.

?

@ocelotl
Copy link
Contributor

ocelotl commented Jul 2, 2024

So, I tried this:

I ran tox -e lint to create a virtual environment with pylint:

Package                                  Version     Editable project location
---------------------------------------- ----------- -------------------------------------------------------------------------------------------------
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
opentelemetry-api                        1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/opentelemetry-api
opentelemetry-exporter-opencensus        0.47b0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-opencensus
opentelemetry-exporter-otlp              1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-otlp
opentelemetry-exporter-otlp-proto-common 1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-otlp-proto-common
opentelemetry-exporter-otlp-proto-grpc   1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-otlp-proto-grpc
opentelemetry-exporter-otlp-proto-http   1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-otlp-proto-http
opentelemetry-exporter-prometheus        0.47b0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-prometheus
opentelemetry-exporter-zipkin            1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-zipkin
opentelemetry-exporter-zipkin-json       1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-zipkin-json
opentelemetry-exporter-zipkin-proto-http 1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/exporter/opentelemetry-exporter-zipkin-proto-http
opentelemetry-opencensus-shim            0.47b0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/shim/opentelemetry-opencensus-shim
opentelemetry-opentracing-shim           0.47b0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/shim/opentelemetry-opentracing-shim
opentelemetry-propagator-b3              1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/propagator/opentelemetry-propagator-b3
opentelemetry-propagator-jaeger          1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/propagator/opentelemetry-propagator-jaeger
opentelemetry-proto                      1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/opentelemetry-proto
opentelemetry-sdk                        1.26.0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/opentelemetry-sdk
opentelemetry-semantic-conventions       0.47b0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/opentelemetry-semantic-conventions
opentelemetry-test-utils                 0.47b0.dev0 /home/tigre/github/ocelotl/opentelemetry-python/tests/opentelemetry-test-utils
opentracing                              2.4.0
packaging                                24.0
pathspec                                 0.12.1
pip                                      24.0
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
setuptools                               70.0.0
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
wheel                                    0.43.0
wrapt                                    1.16.0
zipp                                     3.17.0

I modified this file /home/tigre/github/ocelotl/opentelemetry-python/.tox/lint/lib/python3.11/site-packages/pylint/lint/pylinter.py:

diff --git a/pylinter.py b/pylinter.py
index e21d8b5..233f9e9 100644
--- a/pylinter.py
+++ b/pylinter.py
@@ -874,6 +874,7 @@ class PyLinter(
         for descr in self._expand_files(files_or_modules).values():
             name, filepath, is_arg = descr["name"], descr["path"], descr["isarg"]
             if self.should_analyze_file(name, filepath, is_argument=is_arg):
+                print(name)
                 yield FileItem(name, filepath, descr["basename"])
 
     def _expand_files(

Now, when we run pylint the file being checked is displayed.

I noticed that if I ran pylint opentelemetry-api/tests I got this:

(lint) tigre@hilleman:~/github/ocelotl/opentelemetry-python$ pylint opentelemetry-api/tests
tests
tests.mypysmoke
tests.test_implementation
tests.distributedcontext.__init__
tests.trace.test_immutablespancontext
tests.trace.__init__
tests.trace.test_status
tests.trace.test_globals
tests.trace.test_proxy
tests.trace.test_span_context
tests.trace.test_defaultspan
tests.trace.test_tracer
tests.trace.test_tracestate
tests.context.__init__
tests.context.test_contextvars_context
tests.context.test_context
tests.context.base_context
tests.context.propagation.__init__

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

But if I ran pylint opentelemetry-api, I got this:

tests.__init__
tests.mypysmoke
tests.test_implementation
tests.logs.test_logger_provider
tests.logs.test_proxy
tests.logs.test_log_record
tests.propagators.test_composite
tests.propagators.test_w3cbaggagepropagator
tests.propagators.test_propagators
tests.propagators.test_global_httptextformat
tests.attributes.test_attributes
tests.distributedcontext.__init__
tests.util.test_re
tests.util.test__importlib_metadata
tests.util.test__providers
tests.util.test_contextmanager
tests.util.test_once
tests.baggage.test_baggage
tests.baggage.propagation.test_propagation
tests.metrics.test_observation
tests.metrics.test_meter_provider
tests.metrics.test_subclass_instantiation
tests.metrics.test_meter
tests.metrics.test_instruments
tests.trace.test_immutablespancontext
tests.trace.__init__
tests.trace.test_status
tests.trace.test_globals
tests.trace.test_proxy
tests.trace.test_span_context
tests.trace.test_defaultspan
tests.trace.test_tracer
tests.trace.test_tracestate
tests.trace.propagation.test_tracecontexthttptextformat
tests.trace.propagation.test_textmap
tests.context.__init__
tests.context.test_contextvars_context
tests.context.test_context
tests.context.base_context
tests.context.propagation.__init__
opentelemetry.environment_variables
opentelemetry.version
opentelemetry._logs.__init__
opentelemetry._logs._internal.__init__
opentelemetry._logs.severity.__init__
opentelemetry.propagators.textmap
opentelemetry.propagators.composite
opentelemetry.attributes.__init__
opentelemetry.util.re
opentelemetry.util._decorator
opentelemetry.util.types
opentelemetry.util._once
opentelemetry.util._providers
opentelemetry.util._importlib_metadata
opentelemetry.baggage.__init__
opentelemetry.baggage.propagation.__init__
opentelemetry.propagate.__init__
opentelemetry.metrics.__init__
opentelemetry.metrics._internal.__init__
opentelemetry.metrics._internal.observation
opentelemetry.metrics._internal.instrument
opentelemetry.trace.__init__
opentelemetry.trace.status
opentelemetry.trace.span
opentelemetry.trace.propagation.__init__
opentelemetry.trace.propagation.tracecontext
opentelemetry.context.__init__
opentelemetry.context.contextvars_context
opentelemetry.context.context
************* Module tests.logs.test_logger_provider
opentelemetry-api/tests/logs/test_logger_provider.py:34:4: R6301: Method could be a function (no-self-use)
opentelemetry-api/tests/logs/test_logger_provider.py:34:4: R6301: Method could be a function (no-self-use)
opentelemetry-api/tests/logs/test_logger_provider.py:42:4: R6301: Method could be a function (no-self-use)
opentelemetry-api/tests/logs/test_logger_provider.py:42:4: R6301: Method could be a function (no-self-use)
************* Module tests.propagators.test_w3cbaggagepropagator
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:41:12: C0103: Variable name "k" doesn't conform to '(([a-z_][a-z0-9_]{1,})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern ('(([a-z_][a-z0-9_]{1,})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern) (invalid-name)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:41:15: C0103: Variable name "v" doesn't conform to '(([a-z_][a-z0-9_]{1,})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern ('(([a-z_][a-z0-9_]{1,})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern) (invalid-name)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:97:28: W0212: Access to a protected member _MAX_HEADER_LENGTH of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:104:42: W0212: Access to a protected member _MAX_PAIRS of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:107:40: W0212: Access to a protected member _MAX_PAIRS of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:111:28: W0212: Access to a protected member _MAX_PAIR_LENGTH of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:142:51: W0212: Access to a protected member _MAX_PAIR_LENGTH of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:146:32: W0212: Access to a protected member _MAX_PAIRS of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:153:39: W0212: Access to a protected member _MAX_PAIRS of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:173:32: W0212: Access to a protected member _MAX_PAIRS of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:180:39: W0212: Access to a protected member _MAX_PAIRS of a client class (protected-access)
opentelemetry-api/tests/propagators/test_w3cbaggagepropagator.py:29:0: R0904: Too many public methods (23/20) (too-many-public-methods)
************* Module tests.propagators.test_global_httptextformat
opentelemetry-api/tests/propagators/test_global_httptextformat.py:32:28: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
************* Module tests.attributes.test_attributes
opentelemetry-api/tests/attributes/test_attributes.py:24:4: C0103: Method name "assertValid" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]*|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern) (invalid-name)
opentelemetry-api/tests/attributes/test_attributes.py:30:4: C0103: Method name "assertInvalid" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]*|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern) (invalid-name)
opentelemetry-api/tests/attributes/test_attributes.py:114:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:133:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:139:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:151:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:161:8: C0206: Consider iterating with .items() (consider-using-dict-items)
opentelemetry-api/tests/attributes/test_attributes.py:191:13: W0212: Access to a protected member _lock of a client class (protected-access)
************* Module tests.util.test__providers
opentelemetry-api/tests/util/test__providers.py:23:0: C0103: Class name "Test_Providers" doesn't conform to PascalCase naming style ('[^\\W\\da-z][^\\W_]*$' pattern) (invalid-name)
opentelemetry-api/tests/util/test__providers.py:52:12: W0212: Access to a protected member _load_provider of a client class (protected-access)
************* Module tests.metrics.test_meter_provider
opentelemetry-api/tests/metrics/test_meter_provider.py:57:28: W0621: Redefining name 'reset_meter_provider' from outer scope (line 49) (redefined-outer-name)
opentelemetry-api/tests/metrics/test_meter_provider.py:64:11: W0212: Access to a protected member _METER_PROVIDER of a client class (protected-access)
opentelemetry-api/tests/metrics/test_meter_provider.py:68:11: W0212: Access to a protected member _METER_PROVIDER of a client class (protected-access)
opentelemetry-api/tests/metrics/test_meter_provider.py:72:49: W0621: Redefining name 'reset_meter_provider' from outer scope (line 49) (redefined-outer-name)
opentelemetry-api/tests/metrics/test_meter_provider.py:76:15: W0212: Access to a protected member _PROXY_METER_PROVIDER of a client class (protected-access)
opentelemetry-api/tests/metrics/test_meter_provider.py:84:28: W0621: Redefining name 'reset_meter_provider' from outer scope (line 49) (redefined-outer-name)
opentelemetry-api/tests/metrics/test_meter_provider.py:89:11: W0212: Access to a protected member _METER_PROVIDER of a client class (protected-access)
opentelemetry-api/tests/metrics/test_meter_provider.py:93:4: W0212: Access to a protected member _METER_PROVIDER of a client class (protected-access)
opentelemetry-api/tests/metrics/test_meter_provider.py:116:15: W0718: Catching too general exception Exception (broad-exception-caught)
opentelemetry-api/tests/metrics/test_meter_provider.py:180:4: R0915: Too many statements (55/50) (too-many-statements)
************* Module tests.metrics.test_subclass_instantiation
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:54:4: W0221: Number of parameters was 4 in 'Meter.create_counter' and is now 4 in overriding 'MeterImplTest.create_counter' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:57:4: W0221: Number of parameters was 4 in 'Meter.create_up_down_counter' and is now 4 in overriding 'MeterImplTest.create_up_down_counter' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:60:4: W0221: Number of parameters was 5 in 'Meter.create_observable_counter' and is now 4 in overriding 'MeterImplTest.create_observable_counter' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:63:4: W0221: Number of parameters was 4 in 'Meter.create_histogram' and is now 4 in overriding 'MeterImplTest.create_histogram' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:66:4: W0221: Number of parameters was 5 in 'Meter.create_observable_gauge' and is now 4 in overriding 'MeterImplTest.create_observable_gauge' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:69:4: W0221: Number of parameters was 5 in 'Meter.create_observable_up_down_counter' and is now 4 in overriding 'MeterImplTest.create_observable_up_down_counter' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:79:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:103:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:108:4: W0221: Number of parameters was 3 in 'Counter.add' and is now 3 in overriding 'CounterImplTest.add' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:118:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:123:4: W0221: Number of parameters was 3 in 'UpDownCounter.add' and is now 3 in overriding 'UpDownCounterImplTest.add' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:145:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:150:4: W0221: Number of parameters was 3 in 'Histogram.record' and is now 3 in overriding 'HistogramImplTest.record' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:160:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:165:4: W0221: Number of parameters was 3 in 'Gauge.set' and is now 3 in overriding 'GaugeImplTest.set' method (arguments-differ)
opentelemetry-api/tests/metrics/test_subclass_instantiation.py:175:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
************* Module tests.metrics.test_meter
opentelemetry-api/tests/metrics/test_meter.py:34:4: W0237: Parameter 'callbacks' has been renamed to 'callback' in overriding 'ChildMeter.create_observable_counter' method (arguments-renamed)
opentelemetry-api/tests/metrics/test_meter.py:47:4: W0237: Parameter 'callbacks' has been renamed to 'callback' in overriding 'ChildMeter.create_observable_gauge' method (arguments-renamed)
opentelemetry-api/tests/metrics/test_meter.py:52:4: W0237: Parameter 'callbacks' has been renamed to 'callback' in overriding 'ChildMeter.create_observable_up_down_counter' method (arguments-renamed)
opentelemetry-api/tests/metrics/test_meter.py:75:15: W0718: Catching too general exception Exception (broad-exception-caught)
opentelemetry-api/tests/metrics/test_meter.py:105:24: E1101: Method 'create_counter' has no '__isabstractmethod__' member (no-member)
opentelemetry-api/tests/metrics/test_meter.py:113:24: E1101: Method 'create_up_down_counter' has no '__isabstractmethod__' member (no-member)
opentelemetry-api/tests/metrics/test_meter.py:121:24: E1101: Method 'create_observable_counter' has no '__isabstractmethod__' member (no-member)
opentelemetry-api/tests/metrics/test_meter.py:129:24: E1101: Method 'create_histogram' has no '__isabstractmethod__' member (no-member)
opentelemetry-api/tests/metrics/test_meter.py:144:24: E1101: Method 'create_observable_gauge' has no '__isabstractmethod__' member (no-member)
opentelemetry-api/tests/metrics/test_meter.py:154:12: E1101: Method 'create_observable_up_down_counter' has no '__isabstractmethod__' member (no-member)
************* Module tests.metrics.test_instruments
opentelemetry-api/tests/metrics/test_instruments.py:39:4: W0246: Useless parent or super() delegation in method '__init__' (useless-parent-delegation)
opentelemetry-api/tests/metrics/test_instruments.py:615:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:621:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:627:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:633:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:639:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:647:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:652:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:657:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:662:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:667:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:672:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:682:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:688:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:695:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:700:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:705:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:716:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
opentelemetry-api/tests/metrics/test_instruments.py:722:12: W0212: Access to a protected member _check_name_unit_description of a client class (protected-access)
************* Module tests.trace.propagation.test_tracecontexthttptextformat
opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py:50:28: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)

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

So, it seems like we just need to run pylint from the root folder?

@ocelotl
Copy link
Contributor

ocelotl commented Jul 2, 2024

Seems like the fix is pretty easy, we just need to run pylint pointing to the root folder of every package. We already have that almost ready in #3902, if we merge that we can easily open a new PR that changes the pylint commands to point to the root folder.

@ocelotl
Copy link
Contributor

ocelotl commented Jul 2, 2024

I tried implementing this in the contrib repo, apparently it is also important that pylint is run in the directory that contains the directory being checked.

@aabmass
Copy link
Member Author

aabmass commented Jul 12, 2024

I tried implementing this in the contrib repo, apparently it is also important that pylint is run in the directory that contains the directory being checked.

I don't think that is necessary if you set

Do you actually mean

EDIT yup that actually fixes it. I tried adding __init__.py files and pylint correctly discovers the test files.

?

I think either way would do the trick. It expects namespaces packages with no __init__.py OR plain old python packages with __init__.py in every subpackage.

ocelotl added a commit to ocelotl/opentelemetry-python that referenced this issue Jul 12, 2024
@ocelotl
Copy link
Contributor

ocelotl commented Jul 12, 2024

I tried implementing this in the contrib repo, apparently it is also important that pylint is run in the directory that contains the directory being checked.

I don't think that is necessary if you set

Sorry, set what? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build & infra Issues related to build & infrastructure.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants