frequenz-floss / frequenz-repo-config-python

Frequenz repository setup tools and common configuration for Python
https://frequenz-floss.github.io/frequenz-repo-config-python/
MIT License
4 stars 7 forks source link

Optimize Pylint Directives in Package Import Tests within Pytest Folder #156

Open TalweSingh opened 12 months ago

TalweSingh commented 12 months ago

What's needed?

The current implementation has repetitive pylint directives that disable the "import-outside-toplevel" check on multiple lines within the functions. This repetition can be reduced.

Proposed solution



"""Tests for the ... package."""

+    # pylint: disable=import-outside-toplevel

def test_package_import() -> None:
    """Test that the package can be imported."""
-    # pylint: disable=import-outside-toplevel
    from frequenz.api import weather

    assert weather is not None

def test_module_import_components() -> None:
    """Test that the modules can be imported."""
-    # pylint: disable=import-outside-toplevel
-    from frequenz.api.weather import weather_pb2
-
-    assert weather_pb2 is not None
-
-    # pylint: disable=import-outside-toplevel
-    from frequenz.api.weather import weather_pb2_grpc
+    # pylint: disable=import-outside-toplevel
+    from frequenz.api.weather import weather_pb2, weather_pb2_grpc

+   assert weather_pb2 is not None
    assert weather_pb2_grpc is not None
``

### Use cases

_No response_

### Alternatives and workarounds

_No response_

### Additional context

_No response_
llucax commented 11 months ago

Feel free to send the diff as a PR instead :innocent: