Skip to content

Commit

Permalink
chore: update typing in textfsm parse helper func
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmontanari committed Oct 20, 2024
1 parent 6dd94db commit 5829eff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scrapli/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import importlib.resources
import sys
import urllib.request
from io import BytesIO, TextIOWrapper
from io import BufferedReader, BytesIO, TextIOWrapper
from pathlib import Path
from shutil import get_terminal_size
from typing import Any, Dict, List, Optional, TextIO, Tuple, Union
Expand Down Expand Up @@ -119,6 +119,8 @@ def textfsm_parse(
"""
import textfsm # pylint: disable=C0415

template_file: Union[BufferedReader, TextIOWrapper]

if not isinstance(template, TextIOWrapper):
if template.startswith("http://") or template.startswith("https://"):
with urllib.request.urlopen(template) as response:
Expand All @@ -127,7 +129,7 @@ def textfsm_parse(
encoding=response.headers.get_content_charset(),
)
else:
template_file = TextIOWrapper(open(template, mode="rb")) # pylint: disable=R1732
template_file = open(template, mode="rb") # pylint: disable=R1732
else:
template_file = template
re_table = textfsm.TextFSM(template_file)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/driver/generic/test_generic_async_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging

import pytest

from scrapli.driver.generic.base_driver import ReadCallback
Expand Down
1 change: 1 addition & 0 deletions tests/unit/driver/generic/test_generic_sync_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging

import pytest

from scrapli.driver.generic.base_driver import ReadCallback
Expand Down

0 comments on commit 5829eff

Please sign in to comment.