fix: Make mypy happy, few syntax changes
parent
b9239ae3d0
commit
21004dc888
|
@ -8,10 +8,10 @@ import sys
|
|||
from collections.abc import Mapping
|
||||
from contextlib import suppress
|
||||
from glob import glob
|
||||
from ipaddress import ip_network, IPv6Address, IPv4Address, IPv4Network, IPv6Network, _BaseNetwork, \
|
||||
from ipaddress import ip_network, IPv6Address, IPv4Address, IPv4Network, _BaseNetwork, \
|
||||
AddressValueError, NetmaskValueError
|
||||
from pathlib import Path
|
||||
from typing import Union, Dict, Any, List, Optional, Tuple
|
||||
from typing import Union, Dict, Any, List, Optional, Tuple, Sequence
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from . import tools
|
||||
|
@ -32,7 +32,6 @@ def json_default(obj: 'WarningList') -> Union[Dict, str]:
|
|||
return obj.to_dict()
|
||||
|
||||
|
||||
|
||||
class WarningList():
|
||||
|
||||
expected_types = ['string', 'substring', 'hostname', 'cidr', 'regex']
|
||||
|
@ -189,7 +188,7 @@ class NetworkFilter:
|
|||
if child is not True:
|
||||
child.append(net)
|
||||
|
||||
def _get_digit(self, ip:int) -> int:
|
||||
def _get_digit(self, ip: int) -> int:
|
||||
return (ip >> self.digit_position) & 1
|
||||
|
||||
def __repr__(self):
|
||||
|
@ -212,7 +211,7 @@ def compile_network_filters(values: list) -> Tuple[NetworkFilter, NetworkFilter]
|
|||
return ipv4_filter, ipv6_filter
|
||||
|
||||
|
||||
def convert_networks(values: list) -> List[_BaseNetwork]:
|
||||
def convert_networks(values: list) -> Sequence[_BaseNetwork]:
|
||||
valid_ips = []
|
||||
invalid_ips = []
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import os
|
|||
import unittest
|
||||
|
||||
from glob import glob
|
||||
from ipaddress import IPv4Network
|
||||
from ipaddress import IPv4Network
|
||||
|
||||
from pymispwarninglists import WarningLists, tools, WarningList
|
||||
from pymispwarninglists.api import compile_network_filters, NetworkFilter
|
||||
|
@ -63,6 +63,9 @@ class TestPyMISPWarningLists(unittest.TestCase):
|
|||
|
||||
|
||||
class TestCidrList(unittest.TestCase):
|
||||
|
||||
cidr_list: WarningList
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.cidr_list = WarningList(
|
||||
|
|
Loading…
Reference in New Issue