-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monkeytype Juniper family. #254
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #254 +/- ##
=======================================
Coverage 91.08% 91.09%
=======================================
Files 98 98
Lines 22058 22076 +18
Branches 3315 3315
=======================================
+ Hits 20092 20110 +18
Misses 1279 1279
Partials 687 687
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
aerleon/lib/juniper.py
Outdated
def _Comment(self, addr, exclude=False, line_length=132): | ||
def _Comment( | ||
self, addr: Union[IPv6, IPv4, DSMNet], exclude: bool = False, line_length: int = 132 | ||
) -> List[Union[Any, str]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Looking at the code, I think the return type is
List[str]
. - The docstring for argument
addr
is out of date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -848,7 +856,7 @@ def _Comment(self, addr, exclude=False, line_length=132): | |||
logging.warning('Ignoring non IPv4 or IPv6 address: %s', addr) | |||
return rval | |||
|
|||
def _Group(self, group, lc=True): | |||
def _Group(self, group: List[Union[int, Tuple[int, int], str]], lc: bool = True) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily in scope, but just spotted this duplicated expression on line 883:
if isinstance(el, str) or isinstance(el, str):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
aerleon/lib/junipermsmpc.py
Outdated
@@ -416,7 +419,7 @@ def _BuildPort(self, ports): | |||
port_list.append('%s-%s' % (str(p[0]), str(p[1]))) | |||
return port_list | |||
|
|||
def _GenerateApplications(self, filter_name): | |||
def _GenerateApplications(self, filter_name: str) -> List[Union[Any, str]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type is List[str]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
aerleon/lib/junipermsmpc.py
Outdated
@@ -399,7 +402,7 @@ def _BuildTokens(self): | |||
) | |||
return supported_tokens, supported_sub_tokens | |||
|
|||
def _BuildPort(self, ports): | |||
def _BuildPort(self, ports: List[Union[Any, List[int], Tuple[int, int]]]) -> List[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Monkeytype seems to have noticed this function is called with lists instead of tuples sometimes, and sure enough on line 616 (pre-changes), _TranslatePolicy
constructs a list instead of a tuple to represent a port range. I'd suggest clamping the type to List[Tuple[int, int]]
and then cleaning up line 616 to use a tuple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
aerleon/lib/junipersrx.py
Outdated
@@ -613,7 +615,7 @@ def _TranslatePolicy(self, pol, exp_info): | |||
|
|||
self.srx_policies.append((header, new_terms, filter_options)) | |||
|
|||
def _FixLargePolices(self, terms, address_family): | |||
def _FixLargePolices(self, terms: List[Any], address_family: str) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"terms" is List[policy.Term]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
aerleon/lib/junipersrx.py
Outdated
@@ -675,7 +677,7 @@ def Chunks(addresses): | |||
del terms[:] | |||
terms.extend(expanded_terms) | |||
|
|||
def _BuildPort(self, ports): | |||
def _BuildPort(self, ports: List[Union[Any, Tuple[int, int]]]) -> List[Union[Any, str]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both "Any" hints can be removed. The type for "ports" is List[Tuple[int, int]]
and the return type is List[str]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.