Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ repos:
hooks:
- id: mypy
additional_dependencies: []
- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.2
hooks:
- id: cython-lint
- id: double-quote-cython-strings
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,7 @@ build-backend = "poetry.core.masonry.api"

[tool.codespell]
ignore-words-list = ["additionals", "HASS"]

[tool.cython-lint]
max-line-length = 88
ignore = ['E501'] # too many to fix right now
50 changes: 12 additions & 38 deletions src/zeroconf/_cache.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ cdef unsigned int _TYPE_PTR
cdef cython.uint _ONE_SECOND
cdef unsigned int _MIN_SCHEDULED_RECORD_EXPIRATION

@cython.locals(
record_cache=dict,
)

@cython.locals(record_cache=dict)
cdef _remove_key(cython.dict cache, object key, DNSRecord record)


Expand All @@ -37,36 +36,23 @@ cdef class DNSCache:

cpdef void async_remove_records(self, object entries)

@cython.locals(
store=cython.dict,
)
@cython.locals(store=cython.dict)
cpdef DNSRecord async_get_unique(self, DNSRecord entry)

@cython.locals(
record=DNSRecord,
)
@cython.locals(record=DNSRecord)
cpdef list async_expire(self, double now)

@cython.locals(
records=cython.dict,
record=DNSRecord,
)
@cython.locals(records=cython.dict, record=DNSRecord)
cpdef list async_all_by_details(self, str name, unsigned int type_, unsigned int class_)

cpdef list async_entries_with_name(self, str name)

cpdef list async_entries_with_server(self, str name)

@cython.locals(
cached_entry=DNSRecord,
records=dict
)
@cython.locals(cached_entry=DNSRecord, records=dict)
cpdef DNSRecord get_by_details(self, str name, unsigned int type_, unsigned int class_)

@cython.locals(
records=cython.dict,
entry=DNSRecord,
)
@cython.locals(records=cython.dict, entry=DNSRecord)
cpdef cython.list get_all_by_details(self, str name, unsigned int type_, unsigned int class_)

@cython.locals(
Expand All @@ -76,31 +62,19 @@ cdef class DNSCache:
)
cdef bint _async_add(self, DNSRecord record)

@cython.locals(
service_record=DNSService
)
@cython.locals(service_record=DNSService)
cdef void _async_remove(self, DNSRecord record)

@cython.locals(
record=DNSRecord,
created_double=double,
)
@cython.locals(record=DNSRecord, created_double=double)
cpdef void async_mark_unique_records_older_than_1s_to_expire(self, cython.set unique_types, object answers, double now)

@cython.locals(
entries=dict
)
@cython.locals(entries=dict)
cpdef list entries_with_name(self, str name)

@cython.locals(
entries=dict
)
@cython.locals(entries=dict)
cpdef list entries_with_server(self, str server)

@cython.locals(
record=DNSRecord,
now=double
)
@cython.locals(record=DNSRecord, now=double)
cpdef current_entry_with_name_and_alias(self, str name, str alias)

cpdef void _async_set_created_ttl(
Expand Down
3 changes: 1 addition & 2 deletions src/zeroconf/_handlers/answers.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ cdef class AnswerGroup:
cdef public cython.dict answers




cdef object _FLAGS_QR_RESPONSE_AA
cdef object NAME_GETTER

Expand All @@ -31,5 +29,6 @@ cpdef DNSOutgoing construct_outgoing_unicast_answers(
cython.dict answers, bint ucast_source, cython.list questions, object id_
)


@cython.locals(answer=DNSRecord, additionals=cython.set, additional=DNSRecord)
cdef void _add_answers_additionals(DNSOutgoing out, cython.dict answers)
1 change: 0 additions & 1 deletion src/zeroconf/_listener.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ cdef cython.uint _MAX_MSG_ABSOLUTE
cdef cython.uint _DUPLICATE_PACKET_SUPPRESSION_INTERVAL



cdef class AsyncListener:

cdef public object zc
Expand Down
6 changes: 5 additions & 1 deletion src/zeroconf/_services/browser.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cdef class _DNSPointerOutgoingBucket:

cpdef add(self, cython.uint max_compressed_size, DNSQuestion question, cython.set answers)


@cython.locals(cache=DNSCache, question_history=QuestionHistory, record=DNSRecord, qu_question=bint)
cpdef list generate_service_query(
object zc,
Expand All @@ -53,9 +54,11 @@ cpdef list generate_service_query(
object question_type
)


@cython.locals(answer=DNSPointer, query_buckets=list, question=DNSQuestion, max_compressed_size=cython.uint, max_bucket_size=cython.uint, query_bucket=_DNSPointerOutgoingBucket)
cdef list _group_ptr_queries_with_known_answers(double now_millis, bint multicast, cython.dict question_with_known_answers)


cdef class QueryScheduler:

cdef object _zc
Expand Down Expand Up @@ -83,7 +86,7 @@ cdef class QueryScheduler:
@cython.locals(current=_ScheduledPTRQuery, expire_time=double)
cpdef void reschedule_ptr_first_refresh(self, DNSPointer pointer)

@cython.locals(ttl_millis='unsigned int', additional_wait=double, next_query_time=double)
@cython.locals(ttl_millis="unsigned int", additional_wait=double, next_query_time=double)
cpdef void schedule_rescue_query(self, _ScheduledPTRQuery query, double now_millis, float additional_percentage)

cpdef void _process_startup_queries(self)
Expand All @@ -93,6 +96,7 @@ cdef class QueryScheduler:

cpdef void async_send_ready_queries(self, bint first_request, double now_millis, set ready_types)


cdef class _ServiceBrowserBase(RecordUpdateListener):

cdef public cython.set types
Expand Down
7 changes: 5 additions & 2 deletions src/zeroconf/_utils/ipaddress.pxd
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
cdef bint TYPE_CHECKING

from .._dns cimport DNSAddress

cdef bint TYPE_CHECKING


cpdef get_ip_address_object_from_record(DNSAddress record)


@cython.locals(address_str=str)
cpdef str_without_scope_id(object addr)


cpdef ip_bytes_and_scope_to_address(object addr, object scope_id)


cdef object cached_ip_addresses_wrapper