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

Use black and isort #80

Merged
merged 4 commits into from
Jun 11, 2024
Merged
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
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[flake8]
max-line-length = 120
max-line-length = 80
extend-select = B950
extend-ignore = E203,E501,E701
20 changes: 17 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ disable = true
[tool.hatch.envs.default]
dependencies = [
"bandit",
"black~=24.4.2",
"flake8>=7.0.0",
"flake8-bugbear~=24.4.6",
"freezegun",
"isort~=5.13.2",
"mypy",
"pytest",
"pytest-cov",
Expand All @@ -85,16 +88,27 @@ python = ["38", "39", "310", "311", "312"]
detached = true
dependencies = [ # Make sure the respective versions are synced with default!
"bandit",
"flake8>=6.0.0",
"black~=24.4.2",
"flake8>=7.0.0",
"flake8-bugbear~=24.4.6",
"isort~=5.13.2",
]
[tool.hatch.envs.lint.scripts]
flake = "flake8 {args:wtfis}"
security = "bandit --quiet -r {args:wtfis}"
black_check = "black --check wtfis tests"
isort_check = "isort --check-only wtfis tests"
flake = "flake8 wtfis tests"
security = "bandit --quiet -r wtfis"
all = [
"black_check",
"isort_check",
"flake",
"security",
]

# isort
[tool.isort]
profile = "black"

# mypy
[tool.mypy]
ignore_missing_imports = true
Expand Down
19 changes: 10 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from pathlib import Path
from typing import Optional

import pytest
from rich.console import RenderableType
from rich.text import Span, Text

Expand All @@ -13,7 +13,8 @@


class TestTheme:
""" Expected theme values for the tests """
"""Expected theme values for the tests"""

panel_title = "bold yellow"
heading_h1 = "bold bright_green on dark_green"
heading_h2 = "bold yellow"
Expand Down Expand Up @@ -53,40 +54,40 @@ def open_test_data(fname: str) -> str:


def abuseipdb_get_ip(ip, pool) -> AbuseIpDb:
""" Mock replacement for AbuseIpDbClient()._get_ip() """
"""Mock replacement for AbuseIpDbClient()._get_ip()"""
return AbuseIpDb.model_validate(pool[ip])


def greynoise_get(ip, pool) -> GreynoiseIp:
""" Mock replacement for GreynoiseClient().get_ip() """
"""Mock replacement for GreynoiseClient().get_ip()"""
return GreynoiseIp.model_validate(pool[ip])


def ipwhois_get(ip, pool) -> IpWhois:
""" Mock replacement for IpWhoisClient().get_ipwhois() """
"""Mock replacement for IpWhoisClient().get_ipwhois()"""
return IpWhois.model_validate(pool[ip])


def shodan_get_ip(ip, pool) -> ShodanIp:
""" Mock replacement for ShodanClient().get_ip() """
"""Mock replacement for ShodanClient().get_ip()"""
return ShodanIp.model_validate(pool[ip])


def urlhaus_get_host(entity, pool) -> UrlHaus:
""" Mock replacement for UrlHausClient()._get_host() """
"""Mock replacement for UrlHausClient()._get_host()"""
return UrlHaus.model_validate(pool[entity])


def timestamp_text(ts) -> Optional[RenderableType]:
""" Standard timestamp formatting """
"""Standard timestamp formatting"""
theme = TestTheme()
return Text(
ts,
spans=[
Span(10, 11, theme.timestamp_t),
Span(11, 19, theme.timestamp_time),
Span(19, 20, theme.timestamp_z),
]
],
)


Expand Down
Loading
Loading