Skip to content

Commit ce7b363

Browse files
committed
refactor(proxy-checker): tighten anonymity typing and remove unused imports
- remove unused imports (json, os, time, Any) - add `Literal["Transparent","Anonymous","Elite",""]` return type to `parse_anonymity` - change `ProxyChekerResult.anonymity` to `Literal["Transparent","Anonymous","Elite",""]` - import `Literal` where required for stricter static typing
1 parent 676e876 commit ce7b363

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎proxy_checker/ProxyChecker.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import json
2-
import os
31
import random
42
import re
5-
import time
63
from io import BytesIO
7-
from typing import Any, Optional, Union
4+
from typing import Optional, Union, Literal
85

96
import certifi
107
import pycurl
@@ -157,7 +154,9 @@ def send_query(
157154

158155
return {"timeout": timeout, "response": resp_text, "total_time": total_time}
159156

160-
def parse_anonymity(self, response: str) -> str:
157+
def parse_anonymity(
158+
self, response: str
159+
) -> Literal["Transparent", "Anonymous", "Elite", ""]:
161160
if not self.ip:
162161
return ""
163162

‎proxy_checker/ProxyChekerResult.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from dataclasses import dataclass
2-
from typing import List, Optional
2+
from typing import List, Optional, Union, Literal
33
from dataclasses import asdict
44
import json
55

66

77
@dataclass
88
class ProxyChekerResult:
99
protocols: List[str]
10-
anonymity: str
10+
anonymity: Literal["Transparent", "Anonymous", "Elite", ""]
1111
latency: int
1212
country: Optional[str] = None
1313
country_code: Optional[str] = None

0 commit comments

Comments
 (0)