mirror of
https://github.com/certbot/certbot.git
synced 2026-06-04 22:33:00 -04:00
[nginx] Add type hints to nginx configurator for mypy --strict (#10156)
Decided that imports should be in ascii, not caseless, order. If we've done otherwise elsewhere I'll change it. The cast isn't the best but that's what we get for using a dict holding various objects -- the thing marked by `vhost` is going to be a virtualhost so 🤷 `re.findall` can [return](https://docs.python.org/3/library/re.html#re.findall) either a list of strings or a list of tuples of strings, depending what you specify in the regex. In our case it's going to be a list of strings.
This commit is contained in:
parent
f94c981dfd
commit
e8cc2df316
1 changed files with 3 additions and 3 deletions
|
|
@ -477,9 +477,9 @@ class NginxConfigurator(common.Configurator):
|
|||
# Wildcard match - need to find the longest one
|
||||
rank = matches[0]['rank']
|
||||
wildcards = [x for x in matches if x['rank'] == rank]
|
||||
return max(wildcards, key=lambda x: len(x['name']))['vhost']
|
||||
return cast(obj.VirtualHost, max(wildcards, key=lambda x: len(x['name']))['vhost'])
|
||||
# Exact or regex match
|
||||
return matches[0]['vhost']
|
||||
return cast(obj.VirtualHost, matches[0]['vhost'])
|
||||
|
||||
def _rank_matches_by_name(self, vhost_list: Iterable[obj.VirtualHost],
|
||||
target_name: str) -> List[Dict[str, Any]]:
|
||||
|
|
@ -1118,7 +1118,7 @@ class NginxConfigurator(common.Configurator):
|
|||
"""
|
||||
text = self._nginx_version()
|
||||
|
||||
matches = re.findall(r"running with OpenSSL ([^ ]+) ", text)
|
||||
matches: List[str] = re.findall(r"running with OpenSSL ([^ ]+) ", text)
|
||||
if not matches:
|
||||
matches = re.findall(r"built with OpenSSL ([^ ]+) ", text)
|
||||
if not matches:
|
||||
|
|
|
|||
Loading…
Reference in a new issue