Skip to content

add pylintrc file to each indicator #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Oct 30, 2020
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
21 changes: 17 additions & 4 deletions _delphi_utils_python/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
[DESIGN]

min-public-methods=1
[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't scoped just to the test dir right? so adding these lines to have tests lint correctly potentially allows these into the actual module code?

secondarily, how strongly do we feel we need to lint unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they would allow it into the module code, but they seem like narrow enough and innocuous enough problems that they could be caught in review.

If one uses an integrated linter in their IDE, it will read from these files and complain about the tests. FWIW we enforce style the same across implementation and test files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of relying on code review to catch problems that could have been linted, but agree they're pretty innocuous. One option is to add an additional pylintrc to the tests module, so any weird test things can get captured without worrying about affecting the module code. Not sure how clean that is though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about doing this but thought it created a lot of lint files (2 per indicator rather than the necessary 1). Can do if you think it is worthwhile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea that's kind of annoying...I think they're pretty harmless for now, lets just leave as is.

too-few-public-methods

[MESSAGES CONTROL]
[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

disable=R0801, C0330, E1101, E0611, C0114, C0116, C0103, R0913, R0914, W0702
# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions _template_python/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions cdc_covidnet/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions changehc/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions claims_hosp/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions combo_cases_and_deaths/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions emr_hosp/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 17 additions & 4 deletions google_health/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
[DESIGN]

min-public-methods=1
[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[MESSAGES CONTROL]
[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

disable=R0801, C0330, E1101, E0611, C0114, C0116, C0103, R0913, R0914, W0702
# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
2 changes: 1 addition & 1 deletion google_health/delphi_google_health/pull_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def query(self, start_date: str, end_date: str, geo_id, dma=False) -> dict:
start_date,
end_date,
)
data = self.service.getTimelinesForHealth(**params).execute()
data = self.service.getTimelinesForHealth(**params).execute() #pylint: disable=no-member

return data

Expand Down
7 changes: 4 additions & 3 deletions google_health/delphi_google_health/smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ def _left_gauss_linear(s: np.ndarray, h=10, impute=False, minval=None) -> np.nda

n = len(s)
t = np.zeros_like(s, dtype=np.float64)
X = np.vstack([np.ones(n), np.arange(n)]).T
X = np.vstack([np.ones(n), np.arange(n)]).T #pylint: disable=invalid-name
for idx in range(n):
wts = np.exp(-((np.arange(idx + 1) - idx) ** 2) / (h ** 2))
XwX = np.dot(X[: (idx + 1), :].T * wts, X[: (idx + 1), :])
Xwy = np.dot(X[: (idx + 1), :].T * wts, s[: (idx + 1)].reshape(-1, 1))
XwX = np.dot(X[: (idx + 1), :].T * wts, X[: (idx + 1), :]) #pylint: disable=invalid-name
Xwy = np.dot(X[: (idx + 1), :].T * wts, #pylint: disable=invalid-name
s[: (idx + 1)].reshape(-1, 1))
try:
beta = np.linalg.solve(XwX, Xwy)
t[idx] = np.dot(X[: (idx + 1), :], beta)[-1]
Expand Down
21 changes: 17 additions & 4 deletions jhu/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
[DESIGN]

min-public-methods=1
[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[MESSAGES CONTROL]
[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

disable=R0801, C0330, E1101, E0611, C0114, C0116, C0103, R0913, R0914, W0702
# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
3 changes: 2 additions & 1 deletion jhu/delphi_jhu/geo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
"""Functions for translating between geocodes."""
import pandas as pd
from delphi_utils import GeoMapper

VALID_GEO_RES = ("county", "state", "msa", "hrr")
INCIDENCE_BASE = 100000

def geo_map(df: pd.DataFrame, geo_res: str):
Expand All @@ -27,7 +29,6 @@ def geo_map(df: pd.DataFrame, geo_res: str):
Columns: geo_id, timestamp, ...
"""
df = df.copy()
VALID_GEO_RES = ("county", "state", "msa", "hrr")
if geo_res not in VALID_GEO_RES:
raise ValueError(f"geo_res must be one of {VALID_GEO_RES}")

Expand Down
1 change: 1 addition & 0 deletions jhu/delphi_jhu/pull.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
"""Functions to pull data from JHU website."""

import pandas as pd
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion jhu/delphi_jhu/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@


def run_module():

"""Run the JHU indicator module."""
params = read_params()
export_start_date = params["export_start_date"]
export_dir = params["export_dir"]
Expand Down
2 changes: 2 additions & 0 deletions jhu/delphi_jhu/smooth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
'''Functions to smooth signals.'''

import numpy as np

def identity(x):
Expand Down
21 changes: 17 additions & 4 deletions nchs_mortality/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
[DESIGN]

min-public-methods=1
[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[MESSAGES CONTROL]
[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

disable=R0801, C0330, E1101, E0611, C0114, C0116, C0103, R0913, R0914, W0702
# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 21 additions & 0 deletions quidel/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
21 changes: 17 additions & 4 deletions quidel_covidtest/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
[DESIGN]

min-public-methods=1
[MESSAGES CONTROL]

disable=logging-format-interpolation,
too-many-locals,
too-many-arguments,
# Allow pytest functions to be part of a class.
no-self-use,
# Allow pytest classes to have one test.
too-few-public-methods

[MESSAGES CONTROL]
[BASIC]

# Allow arbitrarily short-named variables.
variable-rgx=[a-z_][a-z0-9_]*
argument-rgx=[a-z_][a-z0-9_]*

[DESIGN]

disable=R0801, C0330, E1101, E0611, C0114, C0116, C0103, R0913, R0914, W0702
# Don't complain about pytest "unused" arguments.
ignored-argument-names=(_.*|run_as_module)
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def generate_sensor_for_other_geores(state_groups, data, res_key, smooth,
res_group = res_group.merge(parent_group, how="left",
on="timestamp", suffixes=('', '_parent'))
res_group = res_group.drop(columns=[res_key, "state_id", "state_id" + '_parent'])
except:
except KeyError:
has_parent = False
res_group = res_group.drop(columns=[res_key, "state_id"])
res_group.set_index("timestamp", inplace=True)
Expand Down
Loading