| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 23fdcce commit 1f33c4f
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,4 +9,4 @@ Thumbs.db | |||
| 9 | 9 | .idea | |
| 10 | 10 | .vslick | |
| 11 | 11 | .cache | |
| 12 | - | ||
| 12 | + .mypy_cache/ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,9 +8,12 @@ matrix: | |||
| 8 | 8 | fast_finish: true | |
| 9 | 9 | install: | |
| 10 | 10 | - pip install -r requirements-dev.txt | |
| 11 | + # mypy can't be installed on pypy | ||
| 12 | + - if [[ "${TRAVIS_PYTHON_VERSION}" != "pypy3.5-5.8.0" ]] ; then pip install mypy ; fi | ||
| 11 | 13 | script: | |
| 12 | 14 | - make test_coverage | |
| 13 | 15 | - flake8 --version | |
| 14 | 16 | - make flake8 | |
| 17 | + - if [[ "${TRAVIS_PYTHON_VERSION}" != "pypy3.5-5.8.0" ]] ; then make mypy ; fi | ||
| 15 | 18 | after_success: | |
| 16 | 19 | - coveralls | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,9 @@ env: | |||
| 13 | 13 | flake8: | |
| 14 | 14 | flake8 --max-line-length=$(MAX_LINE_LENGTH) examples *.py | |
| 15 | 15 | ||
| 16 | + mypy: | ||
| 17 | + mypy examples/*.py zeroconf.py | ||
| 18 | + | ||
| 16 | 19 | test: | |
| 17 | 20 | nosetests -v | |
| 18 | 21 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,17 +6,20 @@ | |||
| 6 | 6 | import socket | |
| 7 | 7 | import sys | |
| 8 | 8 | from time import sleep | |
| 9 | + from typing import cast | ||
| 9 | 10 | ||
| 10 | 11 | from zeroconf import ServiceBrowser, ServiceStateChange, Zeroconf | |
| 11 | 12 | ||
| 12 | 13 | ||
| 13 | - def on_service_state_change(zeroconf, service_type, name, state_change): | ||
| 14 | + def on_service_state_change( | ||
| 15 | + zeroconf: Zeroconf, service_type: str, name: str, state_change: ServiceStateChange, | ||
| 16 | + ) -> None: | ||
| 14 | 17 | print("Service %s of type %s state changed: %s" % (name, service_type, state_change)) | |
| 15 | 18 | ||
| 16 | 19 | if state_change is ServiceStateChange.Added: | |
| 17 | 20 | info = zeroconf.get_service_info(service_type, name) | |
| 18 | 21 | if info: | |
| 19 | - print(" Address: %s:%d" % (socket.inet_ntoa(info.address), info.port)) | ||
| 22 | + print(" Address: %s:%d" % (socket.inet_ntoa(cast(bytes, info.address)), cast(int, info.port))) | ||
| 20 | 23 | print(" Weight: %d, priority: %d" % (info.weight, info.priority)) | |
| 21 | 24 | print(" Server: %s" % (info.server,)) | |
| 22 | 25 | if info.properties: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,9 +29,9 @@ | |||
| 29 | 29 | r.get_service_info("_http._tcp.local.", "ZOE._http._tcp.local."))) | |
| 30 | 30 | print(" Query done.") | |
| 31 | 31 | print("3. Testing query of own service...") | |
| 32 | - info = r.get_service_info("_http._tcp.local.", "My Service Name._http._tcp.local.") | ||
| 33 | - assert info | ||
| 34 | - print(" Getting self: %s" % (info,)) | ||
| 32 | + queried_info = r.get_service_info("_http._tcp.local.", "My Service Name._http._tcp.local.") | ||
| 33 | + assert queried_info | ||
| 34 | + print(" Getting self: %s" % (queried_info,)) | ||
| 35 | 35 | print(" Query done.") | |
| 36 | 36 | print("4. Testing unregister of service information...") | |
| 37 | 37 | r.unregister_service(info) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + [mypy] | ||
| 2 | + ignore_missing_imports = true | ||
| 3 | + follow_imports = error | ||
| 4 | + warn_no_return = true | ||
| 5 | + warn_redundant_casts = true | ||
| 6 | + # TODO: disallow untyped defs once we have full type hint coverage | ||
| 7 | + disallow_untyped_defs = false | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,6 @@ coverage | |||
| 4 | 4 | flake8 | |
| 5 | 5 | flake8-blind-except | |
| 6 | 6 | flake8-import-order | |
| 7 | - mypy | ||
| 8 | 7 | # See setup.py comment for why this version is restricted | |
| 9 | 8 | netifaces!=0.10.5 | |
| 10 | 9 | nose | |
| Back | FazBrowse Home | New Git URL |
0 commit comments