Address typing issues hidden by memoization.caching (#322)

This commit is contained in:
bmc-msft
2020-11-18 15:08:40 -05:00
committed by GitHub
parent bb6d083768
commit b2b4a06afa
5 changed files with 41 additions and 1 deletions

View File

@ -212,6 +212,9 @@ jobs:
# set a minimum confidence to ignore known false positives
vulture --min-confidence 61 __app__
../ci/disable-py-cache.sh
mypy __app__ ./tests
afl:
runs-on: ubuntu-18.04
steps:

View File

@ -41,7 +41,7 @@ def get_vm(name: str) -> Optional[VirtualMachine]:
def create_vm(
name: str,
location: str,
location: Region,
vm_sku: str,
image: str,
password: str,

View File

@ -47,6 +47,8 @@ class Task(BASE_TASK, ORMMixin):
) -> Union["Task", Error]:
if config.vm:
os = get_os(config.vm.region, config.vm.image)
if isinstance(os, Error):
return os
elif config.pool:
pool = Pool.get_by_name(config.pool.pool_name)
if isinstance(pool, Error):

18
src/ci/disable-py-cache.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# Temporary work-around to improve the efficacy of static analysis of functions
# decorated with memoization.cached.
#
# For more information:
# https://github.com/lonelyenvoy/python-memoization/issues/16
set -ex
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
sed -i "s/^from memoization import cached/##### from memoization import cached/" $(find . -name '*.py' -not -path .python_packages)
sed -i "s/^@cached/##### @cached/" $(find . -name '*.py' -not -path .python_packages)

17
src/ci/enable-py-cache.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# Temporary work-around to improve the efficacy of static analysis of functions
# decorated with memoization.cached.
#
# For more information:
# https://github.com/lonelyenvoy/python-memoization/issues/16
set -ex
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
sed -i "s/^##### from memoization import cached/from memoization import cached/" $(find . -name '*.py' -not -path .python_packages)
sed -i "s/^##### @cached/@cached/" $(find . -name '*.py' -not -path .python_packages)