Skip to content

Commit 32947a1

Browse files
authored
Address CI messages (#3)
* address pyright messages * update vscode settings * enable test coverage * publish coverage data
1 parent 3843b6b commit 32947a1

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ jobs:
3939
npx pyright
4040
- name: Test with pytest
4141
run: |
42-
pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=com --cov-report=xml --cov-report=html
42+
pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=msrc.appconfig --cov=msrc.appconfig_decl --cov-report=xml --cov-report=html
4343
- name: Upload pytest test results
4444
uses: actions/upload-artifact@v2
4545
with:
4646
name: pytest-results-${{ matrix.python-version }}
47-
path: junit/test-results-${{ matrix.python-version }}.xml
47+
path: |
48+
junit/test-results-${{ matrix.python-version }}.xml
49+
coverage.xml
50+
htmlcov
4851
# Use always() to always run this step to publish test results when there are test failures
4952
if: ${{ always() }}

.vscode/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"python.pythonPath": "c:\\v\\github\\microsoft\\msrc-appconfig\\.venv\\Scripts\\python.exe",
3-
"python.analysis.typeCheckingMode": "basic",
2+
"python.analysis.typeCheckingMode": "strict",
43
"python.analysis.extraPaths": [
54
"msrc-appconfig",
65
"msrc-appconfig/tests",
76
"msrc-appconfig-attrs",
87
"msrc-appconfig-dataclasses",
98
"msrc-appconfig-param"
109
],
11-
"python.testing.pytestEnabled": true
10+
"python.testing.pytestEnabled": true,
11+
"python.linting.flake8Enabled": true
1212
}

api_md.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def write_fun(fn: FunctionType, f: TextIOWrapper):
7979
with open("API.md", "w", encoding="utf8") as f:
8080
writelines(f, [
8181
f"<!--\n THIS FILE HAS BEEN AUTO-GENERATED BY {__file__}\n-->",
82-
f"# {pkg.__name__}", '', trim(pkg.__doc__), '',
82+
f"# {pkg.__name__}", '', trim(pkg.__doc__ or ''), '',
8383
'| Functions | |', '| --- | --- |'])
8484
writelines(f, [
8585
summary_row(getattr(pkg, fn)) for fn in pkg.__all__
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import logging
22

33

4-
logger = logging.getLogger(__package__)
4+
logger: logging.Logger = logging.getLogger(__package__)

msrc-appconfig/msrc/appconfig/read_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def log_discovered(
218218
for v in discovered.values():
219219
logger.info("final %s", v)
220220
# check required fileds
221-
missing_fileds = set()
221+
missing_fileds: ty.Set[str] = set()
222222
for name, el in schema.deep_items():
223223
if not el.has_default:
224224
if name not in discovered.keys():

msrc-appconfig/msrc/appconfig/schema.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def __init__(self,
125125
length: int,
126126
parse_to_list: bool = False
127127
):
128-
self.length = int(length)
128+
self.length: int = int(length)
129129
if self.length < 0:
130130
raise ValueError(
131131
"Tuple length must be 0 (unrestricted) or a positive integer.")
@@ -169,11 +169,11 @@ def __init__(
169169
help: Optional[str] = None,
170170
is_secret: bool = False
171171
):
172-
self.help = help
172+
self.help: Optional[str] = help
173173
_validate_element_type(element_type)
174-
self.element_type = element_type
175-
self.is_secret = is_secret
176-
self.has_default = has_default
174+
self.element_type: ElementType = element_type
175+
self.is_secret: bool = is_secret
176+
self.has_default: bool = has_default
177177
self.default_value = default_value
178178
if has_default and not self.type_check(default_value):
179179
raise ValueError("Element default value %r must have type %r."
@@ -293,7 +293,7 @@ def parseBase(v: object) -> object:
293293
generator = map(parseBase, values)
294294
if t.parse_to_list:
295295
return cast(ConfigValueType, list(generator))
296-
return tuple(generator)
296+
return cast(ConfigValueType, tuple(generator))
297297
if isinstance(self.element_type, AtomicType):
298298
return parseAtomic(self.element_type, value)
299299
elif isinstance(self.element_type, TupleType):
@@ -399,7 +399,7 @@ def interpret_type(t: type) -> Optional[ElementType]:
399399
400400
Returns a type label or None for unsupported types."""
401401
def tryAtomic(t: type) -> Optional[
402-
Union[AtomicType, Type[Enum], Schema[object]]]:
402+
Union[AtomicType, Type[Enum], Schema[Any]]]:
403403
try:
404404
if issubclass(t, Enum):
405405
return t
@@ -411,7 +411,8 @@ def tryAtomic(t: type) -> Optional[
411411
return AtomicType.INT
412412
if issubclass(t, float):
413413
return AtomicType.FLOAT
414-
return Schema(t)
414+
return Schema(t) # type: ignore
415+
# Schema constructor raises runtime exceptions for improper types
415416
except (TypeError, ValueError):
416417
return None
417418

0 commit comments

Comments
 (0)