COVID-IWG / epimargin

networked, stochastic SIRD epidemiological model with Bayesian parameter estimation and policy scenario comparison tools
https://www.adaptivecontrol.org/
MIT License
9 stars 5 forks source link

Lint errors in core files #123

Open dilawar opened 3 years ago

dilawar commented 3 years ago

https://github.com/openjournals/joss-reviews/issues/3464 | Related #117.

I am running a few lint tools e.g., pylint and pyflakes to locate errors in the module. This is related to #117 that also used studies folder. Since that may not be part of final release (https://github.com/COVID-IWG/epimargin/issues/117#issuecomment-885935277), this run restricts itself to the core files.

I am working on my fork and send a PR soon that will fix these issues if possible.

In this run, I am using poetry to manage the dependencies. Managing dependencies in Python has been less than ideal (poetry helps but the author need not add this to their DevOps).

The most critical among these should be fixed.

pylint

$ poetry run pylint -E epimargin
[dilawars@chutki epimargin (poetry)]$ poetry run pylint -E epimargin
************* Module epimargin.policy
epimargin/policy.py:205:15: E1101: Instance of 'VaccinationPolicy' has no 'daily_doses' member (no-member)
************* Module epimargin.estimators
epimargin/estimators.py:25:18: E1101: Method 'params' has no 'join' member (no-member)
************* Module epimargin.plots
epimargin/plots.py:62:0: E0102: function already defined line 14 (function-redefined)
epimargin/plots.py:194:0: E0102: function already defined line 14 (function-redefined)
************* Module epimargin.etl.covid19india
epimargin/etl/covid19india.py:348:22: E1101: Instance of 'TextFileReader' has no 'set_index' member (no-member)
************* Module epimargin.etl.devdatalab
epimargin/etl/devdatalab.py:28:57: E1101: Instance of 'TextFileReader' has no 'O_StateCensus2011' member (no-member)
************* Module epimargin.etl.csse
epimargin/etl/csse.py:27:8: E1101: Instance of 'TextFileReader' has no 'assign' member (no-member)
************* Module epimargin.etl
epimargin/etl/__init__.py:2:11: E0604: Invalid object 'download_data' in __all__, must contain only strings (invalid-all-object)
[dilawars@chutki epimargin (poetry)]$\

mypy

[dilawars@chutki epimargin (poetry)]$ poetry run mypy --ignore-missing-imports epimargin
epimargin/etl/commons.py:2: error: Library stubs not installed for "requests" (or incompatible with Python 3.9)
epimargin/etl/commons.py:2: note: Hint: "python3 -m pip install types-requests"
epimargin/etl/commons.py:2: note: (or run "mypy --install-types" to install all missing stub packages)
epimargin/etl/commons.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
epimargin/etl/__init__.py:2: error: Type of __all__ must be "Sequence[str]", not "List[Callable[[Path, str, str], Any]]"
epimargin/etl/devdatalab.py:14: error: Function "numpy.array" is not valid as a type
epimargin/etl/devdatalab.py:14: note: Perhaps you need "Callable[...]" or a callback protocol?
epimargin/etl/devdatalab.py:16: error: Value of type np.array? is not indexable
epimargin/models.py:127: error: "int" has no attribute "copy"
epimargin/models.py:175: error: "int" has no attribute "copy"
epimargin/models.py:250: error: "int" has no attribute "shape"
epimargin/models.py:279: error: Need type annotation for "dV" (hint: "dV: List[<type>] = ...")
epimargin/models.py:283: error: Function "numpy.array" is not valid as a type
epimargin/models.py:283: note: Perhaps you need "Callable[...]" or a callback protocol?
epimargin/models.py:283: error: Signature of "parallel_forward_epi_step" incompatible with supertype "SIR"
epimargin/models.py:448: error: Incompatible types in assignment (expression has type "bool", variable has type "str")
epimargin/models.py:455: error: Incompatible return value type (got "List[Union[_T, int]]", expected "Union[Dict[str, Sequence[float]], Sequence[float]]")
epimargin/models.py:456: error: Incompatible return value type (got "Dict[str, List[Union[_T, int]]]", expected "Union[Dict[str, Sequence[float]], Sequence[float]]")
epimargin/policy.py:19: error: "SIR" has no attribute "set_parameters"
epimargin/policy.py:36: error: Argument 1 to "len" has incompatible type "SIR"; expected "Sized"
epimargin/policy.py:37: error: "SIR" has no attribute "set_parameters"
epimargin/policy.py:43: error: Need type annotation for "Gs" (hint: "Gs: Set[<type>] = ...")
epimargin/policy.py:43: error: Need type annotation for "Ys" (hint: "Ys: Set[<type>] = ...")
epimargin/policy.py:43: error: Need type annotation for "Os" (hint: "Os: Set[<type>] = ...")
epimargin/policy.py:43: error: Need type annotation for "Rs" (hint: "Rs: Set[<type>] = ...")
epimargin/policy.py:46: error: Need type annotation for "unit"
epimargin/policy.py:46: error: Argument 1 to "enumerate" has incompatible type "SIR"; expected "Iterable[<nothing>]"
epimargin/policy.py:79: error: Value of type "SIR" is not indexable
epimargin/policy.py:88: error: Too many arguments for "run" of "SIR"
epimargin/policy.py:91: error: "SIR" has no attribute "gantt"
epimargin/policy.py:96: error: Argument 1 to "len" has incompatible type "SIR"; expected "Sized"
epimargin/policy.py:97: error: "SIR" has no attribute "set_parameters"
epimargin/policy.py:103: error: Need type annotation for "Gs" (hint: "Gs: Set[<type>] = ...")
epimargin/policy.py:103: error: Need type annotation for "Ys" (hint: "Ys: Set[<type>] = ...")
epimargin/policy.py:103: error: Need type annotation for "Os" (hint: "Os: Set[<type>] = ...")
epimargin/policy.py:103: error: Need type annotation for "Rs" (hint: "Rs: Set[<type>] = ...")
epimargin/policy.py:106: error: Need type annotation for "unit"
epimargin/policy.py:106: error: Argument 1 to "enumerate" has incompatible type "SIR"; expected "Iterable[<nothing>]"
epimargin/policy.py:142: error: Value of type "SIR" is not indexable
epimargin/policy.py:151: error: Too many arguments for "run" of "SIR"
epimargin/policy.py:154: error: "SIR" has no attribute "gantt"
epimargin/policy.py:174: error: Value of type "SIR" is not indexable
epimargin/policy.py:176: error: Argument 1 to "len" has incompatible type "SIR"; expected "Sized"
epimargin/policy.py:180: error: Value of type "SIR" is not indexable
epimargin/policy.py:181: error: Too many arguments for "run" of "SIR"
epimargin/policy.py:183: error: Value of type "SIR" is not indexable
epimargin/policy.py:194: error: Function "numpy.array" is not valid as a type
epimargin/policy.py:194: note: Perhaps you need "Callable[...]" or a callback protocol?
epimargin/policy.py:201: error: Function "numpy.array" is not valid as a type
epimargin/policy.py:201: note: Perhaps you need "Callable[...]" or a callback protocol?
epimargin/policy.py:205: error: "VaccinationPolicy" has no attribute "daily_doses"
epimargin/policy.py:209: error: np.array? has no attribute "sum"
epimargin/policy.py:211: error: np.array? has no attribute "sum"
epimargin/policy.py:215: error: Function "numpy.array" is not valid as a type
epimargin/policy.py:215: note: Perhaps you need "Callable[...]" or a callback protocol?
epimargin/policy.py:221: error: Function "numpy.array" is not valid as a type
epimargin/policy.py:221: note: Perhaps you need "Callable[...]" or a callback protocol?
epimargin/policy.py:221: error: Signature of "distribute_doses" incompatible with supertype "VaccinationPolicy"
epimargin/policy.py:223: error: Incompatible return value type (got "Tuple[ndarray, ndarray, ndarray]", expected "Tuple[np.array?]")
epimargin/policy.py:223: error: np.array? has no attribute "shape"
epimargin/policy.py:225: error: No overload variant of "__setitem__" of "list" matches argument types "int", "float"
epimargin/policy.py:225: note: Possible overload variants:
epimargin/policy.py:225: note:     def __setitem__(self, SupportsIndex, int) -> None
epimargin/policy.py:225: note:     def __setitem__(self, slice, Iterable[int]) -> None
epimargin/policy.py:229: error: "int" has no attribute "mean"
epimargin/policy.py:231: error: Incompatible return value type (got "Tuple[Any, Any, Any]", expected "Tuple[np.array?]")
epimargin/policy.py:238: error: Function "numpy.array" is not valid as a type
epimargin/policy.py:238: note: Perhaps you need "Callable[...]" or a callback protocol?
epimargin/policy.py:248: error: Function "numpy.array" is not valid as a type
epimargin/policy.py:248: note: Perhaps you need "Callable[...]" or a callback protocol?
epimargin/policy.py:248: error: Signature of "distribute_doses" incompatible with supertype "VaccinationPolicy"
epimargin/policy.py:250: error: Incompatible return value type (got "Tuple[None, None, None]", expected "Tuple[np.array?]")
epimargin/policy.py:253: error: No overload variant of "__setitem__" of "list" matches argument types "int", "float"
epimargin/policy.py:253: note: Possible overload variants:
epimargin/policy.py:253: note:     def __setitem__(self, SupportsIndex, int) -> None
epimargin/policy.py:253: note:     def __setitem__(self, slice, Iterable[int]) -> None
epimargin/policy.py:256: error: np.array? has no attribute "shape"
epimargin/policy.py:257: error: Value of type np.array? is not indexable
epimargin/policy.py:259: error: Value of type np.array? is not indexable
epimargin/policy.py:260: error: Value of type np.array? is not indexable
epimargin/policy.py:260: error: Unsupported target for indexed assignment (np.array?)
epimargin/policy.py:263: error: Value of type np.array? is not indexable
epimargin/policy.py:264: error: Value of type np.array? is not indexable
epimargin/policy.py:265: error: Unsupported target for indexed assignment (np.array?)
epimargin/policy.py:267: error: Unsupported operand types for + ("None" and "int")
epimargin/policy.py:267: note: Left operand is of type "Optional[int]"
epimargin/policy.py:268: error: Value of type np.array? is not indexable
epimargin/policy.py:268: error: Unsupported target for indexed assignment (np.array?)
epimargin/policy.py:268: error: Unsupported operand types for + ("None" and "int")
epimargin/policy.py:268: note: Left operand is of type "Optional[int]"
epimargin/policy.py:271: error: Incompatible return value type (got "Tuple[ndarray, Any, Any]", expected "Tuple[np.array?]")
epimargin/policy.py:274: error: "int" has no attribute "mean"
epimargin/plots.py:308: error: "SIR" has no attribute "units"
epimargin/plots.py:322: error: "SIR" has no attribute "aggregate"
epimargin/plots.py:380: error: "SIR" has no attribute "aggregate"
epimargin/plots.py:387: error: Need type annotation for "ranges"
epimargin/plots.py:401: error: Incompatible types in assignment (expression has type "List[Any]", variable has type "int")
epimargin/plots.py:405: error: Incompatible types in assignment (expression has type "List[int]", variable has type "int")
epimargin/plots.py:422: error: Value of type "int" is not indexable
epimargin/plots.py:547: error: "Callable[[Any, Any, Any, Any, Any, Any, Any, Any], Any]" has no attribute "horizontal"
epimargin/plots.py:548: error: "Callable[[Any, Any, Any, Any, Any, Any, Any, Any], Any]" has no attribute "vertical"
Found 82 errors in 6 files (checked 13 source files)