From cf704ef8c4dcd2d803ef4063b1fa2f402b583821 Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Fri, 3 Jan 2025 21:50:10 -0500 Subject: [PATCH] Fix pylint warnings in docs/guide/make/*py files --- docs/guide/make/make_io_vars.py | 9 ++++++--- docs/guide/make/make_params.py | 8 +++++--- docs/guide/make/make_uguide.py | 8 ++++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/docs/guide/make/make_io_vars.py b/docs/guide/make/make_io_vars.py index 4802cf66f..39a7ca302 100644 --- a/docs/guide/make/make_io_vars.py +++ b/docs/guide/make/make_io_vars.py @@ -1,6 +1,9 @@ -import taxcalc as tc +""" +Helper functions used in make_uguide.py module. +""" import pandas as pd import numpy as np +import taxcalc as tc def make_io_vars(path, iotype): @@ -34,7 +37,7 @@ def form_one(row): txt = '_IRS Form Location:_ \n' formdict = row.form for yrange in sorted(formdict.keys()): - txt += '{}: {} \n'.format(yrange, formdict[yrange]) + txt += f'{yrange}: {formdict[yrange]} \n' return txt def form(df): @@ -66,7 +69,7 @@ def create_io_df(path, iotype): DataFrame including input and output variables. """ # Read json file and convert to a dict. - with open(path) as vfile: + with open(path, 'r', encoding='utf-8') as vfile: json_text = vfile.read() variables = tc.json_to_dict(json_text) assert isinstance(variables, dict) diff --git a/docs/guide/make/make_params.py b/docs/guide/make/make_params.py index 0d8032311..dd5cf122a 100644 --- a/docs/guide/make/make_params.py +++ b/docs/guide/make/make_params.py @@ -1,5 +1,7 @@ +""" +Helper functions used in make_uguide.py module. +""" import os -from collections import OrderedDict import numpy as np import pandas as pd import taxcalc as tc @@ -14,7 +16,7 @@ END_YEAR_SHORT = 2020 END_YEAR_LONG = 2027 -# Order for policy_params.md. +# Order for policy_params.md SECTION_1_ORDER = ['Parameter Indexing', 'Payroll Taxes', 'Social Security Taxability', @@ -45,7 +47,7 @@ def make_params(path, ptype): Returns: Single string with all parameter information. """ - with open(path) as pfile: + with open(path, 'r', encoding='utf-8') as pfile: json_text = pfile.read() params = tc.json_to_dict(json_text) df = pd.DataFrame(params).transpose().drop('schema') diff --git a/docs/guide/make/make_uguide.py b/docs/guide/make/make_uguide.py index cb59d4624..929e5211a 100644 --- a/docs/guide/make/make_uguide.py +++ b/docs/guide/make/make_uguide.py @@ -9,7 +9,7 @@ import os import sys -# Other scripts in this folder: +# pylint: disable=import-error from make_params import make_params from make_io_vars import make_io_vars @@ -33,6 +33,9 @@ def main(): + """ + High-level logic. + """ # Policy parameters. policy_param_text = make_params(POLICY_PATH, 'policy') write_file(policy_param_text, 'policy_params') @@ -52,7 +55,8 @@ def main(): def write_file(text, file): - """ Writes the concatenation of a template and calculated text to a file. + """ + Writes the concatenation of a template and calculated text to a file. Args: text: String with calculated documentation.