Skip to content

Commit

Permalink
Use black and isort (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
pirxthepilot authored Jun 11, 2024
1 parent 49f04d7 commit 9893ebe
Show file tree
Hide file tree
Showing 39 changed files with 1,225 additions and 744 deletions.
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

0 comments on commit 9893ebe

Please sign in to comment.