Skip to content

Commit

Permalink
[Issue 918] Lint for print in /analytics (#3026)
Browse files Browse the repository at this point in the history
## Summary
Fixes #918 

### Time to review: __1 min__

## Changes proposed
> What was added, updated, or removed in this PR.

Removed T201 from `ignore` array in `pyproject.toml` so that use of
print statements will not be ignored by linter. Added exception for
tests. Removed print from slack integration.

## Context for reviewers
> Testing instructions, background context, more in-depth details of the
implementation, and anything else you'd like to call out or ask
reviewers. Explain how the changes were verified.

## Additional information
> Screenshots, GIF demos, code examples or output to help show the
changes working as expected.
  • Loading branch information
DavidDudas-Intuitial authored Nov 26, 2024
1 parent f51f5db commit 2bd43c0
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 245 deletions.
500 changes: 257 additions & 243 deletions analytics/poetry.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion analytics/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ ignore = [
"PTH123", # `open()` should be replaced by `Path.open()`
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"TD003", # missing an issue link on TODO
"T201", # use of `print` detected
"PT004", # pytest fixture leading underscore - is marked deprecated
"FA102", # Adding "from __future__ import annotations" to any new-style type annotation
]
Expand Down
1 change: 1 addition & 0 deletions analytics/src/analytics/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: T201
# pylint: disable=C0415
"""Expose a series of CLI entrypoints for the analytics package."""

Expand Down
6 changes: 5 additions & 1 deletion analytics/src/analytics/integrations/slack.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ruff: noqa: T201
"""Integrate with Slack to post messages and get channel information."""

import functools
import logging
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any
Expand All @@ -9,6 +11,8 @@
from slack_sdk.errors import SlackApiError
from slack_sdk.web.slack_response import SlackResponse

logger = logging.getLogger(__name__)


@dataclass
class FileMapping:
Expand All @@ -30,7 +34,7 @@ def try_to_make_slackbot_api_call_and_catch_error(
try:
return slackbot_api_call(*args, **kwargs)
except SlackApiError as e:
print(e)
logger.info(e)
return None

return try_to_make_slackbot_api_call_and_catch_error
Expand Down
1 change: 1 addition & 0 deletions analytics/tests/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ ignore = [
"ANN201", # missing return type
"PLR2004", # magic value used in comparison instead of constant
"S101", # Use of `assert` detected
"T201", # use of `print` detected
]

0 comments on commit 2bd43c0

Please sign in to comment.