Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
# Black – run in **check** mode so it *fails* instead of auto‑rewriting
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
args: ["--check"] # ensure code is already formatted

# Ruff – both linter and formatter (import sorting)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.5
hooks:
- id: ruff
args: ["check", "."] # same behaviour CI uses

# Bandit – security checks
- repo: https://github.com/PyCQA/bandit
rev: 1.8.6
hooks:
- id: bandit
args: ["-r", "."]
2 changes: 0 additions & 2 deletions FetchEvent.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/python3

import os
import json
from dotenv import load_dotenv
import pandas as pd
import argparse
import time
import pytz
from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.events_api import EventsApi

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ line-length = 100
ignore = ["E501"] # long lines handled by Black

[tool.bandit]
skips = ["B101"] # adjust to taste
skips = ["B101"] # use of assert outside of test code
25 changes: 25 additions & 0 deletions ruff
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
2025-07-24T14:48:04,534 Using pip 25.1.1 from /home/erik/projects/FetchEvent/venv/lib/python3.10/site-packages/pip (python 3.10)
2025-07-24T14:48:04,534 Non-user install because user site-packages disabled
2025-07-24T14:48:04,620 Created temporary directory: /tmp/pip-build-tracker-_ks5s6lj
2025-07-24T14:48:04,620 Initialized build tracking at /tmp/pip-build-tracker-_ks5s6lj
2025-07-24T14:48:04,620 Created build tracker: /tmp/pip-build-tracker-_ks5s6lj
2025-07-24T14:48:04,620 Entered build tracker: /tmp/pip-build-tracker-_ks5s6lj
2025-07-24T14:48:04,620 Created temporary directory: /tmp/pip-install-6jm2kk0b
2025-07-24T14:48:04,620 Remote version of pip: 25.1.1
2025-07-24T14:48:04,620 Local version of pip: 25.1.1
2025-07-24T14:48:04,620 Was pip installed by pip? True
2025-07-24T14:48:04,621 ERROR: You must give at least one requirement to install (see "pip help install")
2025-07-24T14:48:04,621 Exception information:
2025-07-24T14:48:04,621 Traceback (most recent call last):
2025-07-24T14:48:04,621 File "/home/erik/projects/FetchEvent/venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 105, in _run_wrapper
2025-07-24T14:48:04,621 status = _inner_run()
2025-07-24T14:48:04,621 File "/home/erik/projects/FetchEvent/venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 96, in _inner_run
2025-07-24T14:48:04,621 return self.run(options, args)
2025-07-24T14:48:04,621 File "/home/erik/projects/FetchEvent/venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 68, in wrapper
2025-07-24T14:48:04,621 return func(self, options, args)
2025-07-24T14:48:04,621 File "/home/erik/projects/FetchEvent/venv/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 351, in run
2025-07-24T14:48:04,621 reqs = self.get_requirements(args, options, finder, session)
2025-07-24T14:48:04,621 File "/home/erik/projects/FetchEvent/venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 303, in get_requirements
2025-07-24T14:48:04,621 raise CommandError(
2025-07-24T14:48:04,621 pip._internal.exceptions.CommandError: You must give at least one requirement to install (see "pip help install")
2025-07-24T14:48:04,627 Removed build tracker: '/tmp/pip-build-tracker-_ks5s6lj'
7 changes: 3 additions & 4 deletions tests/test_FetchEvent.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
import pytest # noqa: F401
import os
import pandas as pd
import argparse
from unittest.mock import patch, MagicMock

from FetchEvent import (
initialize_config,
parse_arguments,
Expand All @@ -23,7 +23,6 @@ def test_initialize_config():


def test_parse_arguments():
test_args = ["--query", "test_query", "--days", "7"]
with patch(
"FetchEvent.argparse.ArgumentParser.parse_args",
return_value=argparse.Namespace(query="test_query", days=7),
Expand All @@ -41,8 +40,8 @@ def test_fetch_event_data():


def test_process_event_data():
mock_event_data = [
MagicMock(
mock_event_data = [
id="1",
type="type1",
attributes=MagicMock(
Expand Down
Loading