@@ -134,32 +134,34 @@ def async_get_unique(self, entry: _UniqueRecordsType) -> Optional[DNSRecord]:
134
134
return None
135
135
return store .get (entry )
136
136
137
- def async_all_by_details (self , name : str , type_ : int , class_ : int ) -> Iterator [DNSRecord ]:
137
+ def async_all_by_details (self , name : _str , type_ : int , class_ : int ) -> Iterator [DNSRecord ]:
138
138
"""Gets all matching entries by details.
139
139
140
140
This function is not threadsafe and must be called from
141
141
the event loop.
142
142
"""
143
143
key = name .lower ()
144
- for entry in self .cache .get (key , []) :
144
+ for entry in self .cache .get (key ) or [] :
145
145
if _dns_record_matches (entry , key , type_ , class_ ):
146
146
yield entry
147
147
148
- def async_entries_with_name (self , name : str ) -> Dict [DNSRecord , DNSRecord ]:
148
+ def async_entries_with_name (self , name : _str ) -> Dict [DNSRecord , DNSRecord ]:
149
149
"""Returns a dict of entries whose key matches the name.
150
150
151
151
This function is not threadsafe and must be called from
152
152
the event loop.
153
153
"""
154
- return self .cache .get (name .lower (), {})
154
+ key = name .lower ()
155
+ return self .cache .get (key ) or {}
155
156
156
- def async_entries_with_server (self , name : str ) -> Dict [DNSRecord , DNSRecord ]:
157
+ def async_entries_with_server (self , name : _str ) -> Dict [DNSRecord , DNSRecord ]:
157
158
"""Returns a dict of entries whose key matches the server.
158
159
159
160
This function is not threadsafe and must be called from
160
161
the event loop.
161
162
"""
162
- return self .service_cache .get (name .lower (), {})
163
+ key = name .lower ()
164
+ return self .service_cache .get (key ) or {}
163
165
164
166
# The below functions are threadsafe and do not need to be run in the
165
167
# event loop, however they all make copies so they significantly
@@ -175,7 +177,7 @@ def get(self, entry: DNSEntry) -> Optional[DNSRecord]:
175
177
return cached_entry
176
178
return None
177
179
178
- def get_by_details (self , name : str , type_ : int , class_ : int ) -> Optional [DNSRecord ]:
180
+ def get_by_details (self , name : _str , type_ : int , class_ : int ) -> Optional [DNSRecord ]:
179
181
"""Gets the first matching entry by details. Returns None if no entries match.
180
182
181
183
Calling this function is not recommended as it will only
@@ -193,7 +195,7 @@ def get_by_details(self, name: str, type_: int, class_: int) -> Optional[DNSReco
193
195
return cached_entry
194
196
return None
195
197
196
- def get_all_by_details (self , name : str , type_ : int , class_ : int ) -> List [DNSRecord ]:
198
+ def get_all_by_details (self , name : _str , type_ : int , class_ : int ) -> List [DNSRecord ]:
197
199
"""Gets all matching entries by details."""
198
200
key = name .lower ()
199
201
return [
0 commit comments