Skip to content

Commit 38eab69

Browse files
authored
Add # pragma: no cover for unnecessary code (#987)
1 parent 0ffa7ca commit 38eab69

20 files changed

+28
-26
lines changed

proxy/common/_version.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
try:
1616
# pylint: disable=unused-import
1717
from ._scm_version import version as __version__, version_tuple as _ver_tup # noqa: WPS433, WPS436
18-
except ImportError:
18+
except ImportError: # pragma: no cover
1919
from pkg_resources import get_distribution as _get_dist # noqa: WPS433
2020
__version__ = _get_dist('proxy.py').version # noqa: WPS440
2121

2222

23-
def _to_int_or_str(inp: str) -> Union[int, str]:
23+
def _to_int_or_str(inp: str) -> Union[int, str]: # pragma: no cover
2424
try:
2525
return int(inp)
2626
except ValueError:
2727
return inp
2828

2929

30-
def _split_version_parts(inp: str) -> Tuple[str, ...]:
30+
def _split_version_parts(inp: str) -> Tuple[str, ...]: # pragma: no cover
3131
public_version, _plus, local_version = inp.partition('+')
3232
return (*public_version.split('.'), local_version)
3333

3434

3535
try:
3636
VERSION = _ver_tup
37-
except NameError:
37+
except NameError: # pragma: no cover
3838
VERSION = tuple(
3939
map(_to_int_or_str, _split_version_parts(__version__)),
4040
)

proxy/common/backports.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from collections import deque
1717

1818

19-
class cached_property:
19+
class cached_property: # pragma: no cover
2020
"""Decorator for read-only properties evaluated only once within TTL period.
2121
It can be used to create a cached property like this::
2222
@@ -111,8 +111,8 @@ def get(self) -> Any:
111111

112112
def empty(self) -> bool:
113113
'''Return True if the queue is empty, False otherwise (not reliable!).'''
114-
return len(self._queue) == 0
114+
return len(self._queue) == 0 # pragma: no cover
115115

116116
def qsize(self) -> int:
117117
'''Return the approximate size of the queue (not reliable!).'''
118-
return len(self._queue)
118+
return len(self._queue) # pragma: no cover

proxy/common/logger.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def setup(
3636
log_level: str = DEFAULT_LOG_LEVEL,
3737
log_format: str = DEFAULT_LOG_FORMAT,
3838
) -> None:
39-
if log_file:
39+
if log_file: # pragma: no cover
4040
logging.basicConfig(
4141
filename=log_file,
4242
filemode='a',

proxy/common/types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from typing import TYPE_CHECKING, Dict, Any, List, Tuple, Union
1515

1616

17-
if TYPE_CHECKING:
18-
DictQueueType = queue.Queue[Dict[str, Any]] # pragma: no cover
17+
if TYPE_CHECKING: # pragma: no cover
18+
DictQueueType = queue.Queue[Dict[str, Any]]
1919
else:
2020
DictQueueType = queue.Queue
2121

proxy/common/utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
DEFAULT_TIMEOUT, DEFAULT_THREADLESS, IS_WINDOWS,
2929
)
3030

31-
if not IS_WINDOWS:
31+
if not IS_WINDOWS: # pragma: no cover
3232
import resource
3333

3434
logger = logging.getLogger(__name__)
@@ -282,7 +282,8 @@ def get_available_port() -> int:
282282

283283
def set_open_file_limit(soft_limit: int) -> None:
284284
"""Configure open file description soft limit on supported OS."""
285-
if IS_WINDOWS: # resource module not available on Windows OS
285+
# resource module not available on Windows OS
286+
if IS_WINDOWS: # pragma: no cover
286287
return
287288

288289
curr_soft_limit, curr_hard_limit = resource.getrlimit(

proxy/core/acceptor/acceptor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def _work(self, conn: socket.socket, addr: Optional[Tuple[str, int]]) -> None:
237237
event_queue=self.event_queue,
238238
publisher_id=self.__class__.__name__,
239239
)
240-
logger.debug(
240+
logger.debug( # pragma: no cover
241241
'Started work#{0}.{1}.{2} in thread#{3}'.format(
242242
conn.fileno(), self.idd, self._total, thread.ident,
243243
),

proxy/core/connection/pool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async def handle_events(self, readables: Readables, _writables: Writables) -> bo
139139
has somehow reached an illegal state e.g. upstream sending data for previous
140140
connection acquisition lifecycle."""
141141
for fileno in readables:
142-
if TYPE_CHECKING:
142+
if TYPE_CHECKING: # pragma: no cover
143143
assert isinstance(fileno, int)
144144
logger.debug('Upstream fd#{0} is read ready'.format(fileno))
145145
self._remove(fileno)

proxy/core/work/delegate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from typing import TYPE_CHECKING, Optional, Tuple
1212
from multiprocessing.reduction import send_handle
1313

14-
if TYPE_CHECKING:
14+
if TYPE_CHECKING: # pragma: no cover
1515
import socket
1616
import multiprocessing
1717
from multiprocessing import connection

proxy/core/work/pool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ...common.flag import flags
2121
from ...common.constants import DEFAULT_NUM_WORKERS, DEFAULT_THREADLESS
2222

23-
if TYPE_CHECKING:
23+
if TYPE_CHECKING: # pragma: no cover
2424
from ..event import EventQueue
2525

2626
logger = logging.getLogger(__name__)

proxy/core/work/threaded.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from ..connection import TcpClientConnection
1818
from ..event import EventQueue, eventNames
1919

20-
if TYPE_CHECKING:
20+
if TYPE_CHECKING: # pragma: no cover
2121
from .work import Work
2222

2323

proxy/core/work/threadless.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from ..connection import TcpClientConnection, UpstreamConnectionPool
2929
from ..event import eventNames
3030

31-
if TYPE_CHECKING:
31+
if TYPE_CHECKING: # pragma: no cover
3232
from typing import Any
3333

3434
from ..event import EventQueue

proxy/core/work/work.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ..event import eventNames, EventQueue
2222
from ...common.types import Readables, SelectableEvents, Writables
2323

24-
if TYPE_CHECKING:
24+
if TYPE_CHECKING: # pragma: no cover
2525
from ..connection import UpstreamConnectionPool
2626

2727
T = TypeVar('T')

proxy/http/exception/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""
1515
from typing import Any, Optional, TYPE_CHECKING
1616

17-
if TYPE_CHECKING:
17+
if TYPE_CHECKING: # pragma: no cover
1818
from ..parser import HttpParser
1919

2020

proxy/http/exception/http_request_rejected.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from ...common.utils import build_http_response
1616

17-
if TYPE_CHECKING:
17+
if TYPE_CHECKING: # pragma: no cover
1818
from ..parser import HttpParser
1919

2020

proxy/http/exception/proxy_auth_failed.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from ..responses import PROXY_AUTH_FAILED_RESPONSE_PKT
2121

22-
if TYPE_CHECKING:
22+
if TYPE_CHECKING: # pragma: no cover
2323
from ..parser import HttpParser
2424

2525

proxy/http/exception/proxy_conn_failed.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from ..responses import BAD_GATEWAY_RESPONSE_PKT
2020

21-
if TYPE_CHECKING:
21+
if TYPE_CHECKING: # pragma: no cover
2222
from ..parser import HttpParser
2323

2424

proxy/http/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .descriptors import DescriptorsHandlerMixin
2222
from .mixins import TlsInterceptionPropertyMixin
2323

24-
if TYPE_CHECKING:
24+
if TYPE_CHECKING: # pragma: no cover
2525
from ..core.connection import UpstreamConnectionPool
2626

2727

proxy/http/proxy/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ...core.event import EventQueue
2222
from ...core.connection import TcpClientConnection
2323

24-
if TYPE_CHECKING:
24+
if TYPE_CHECKING: # pragma: no cover
2525
from ...core.connection import UpstreamConnectionPool
2626

2727

proxy/http/server/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ...core.connection import TcpClientConnection
2121
from ...core.event import EventQueue
2222

23-
if TYPE_CHECKING:
23+
if TYPE_CHECKING: # pragma: no cover
2424
from ...core.connection import UpstreamConnectionPool
2525

2626

requirements-testing.txt

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ h2==4.1.0
2121
hpack==4.0.0
2222
hyperframe==6.0.1
2323
pre-commit==2.16.0
24+
types-setuptools==57.4.7

0 commit comments

Comments
 (0)