pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.27k stars 1.13k forks source link

Crash linting some Python functions that read/write Excel workbooks #8069

Closed swong59 closed 1 year ago

swong59 commented 1 year ago

Bug description

pylint-crash-2023-01-17-19-47-31.txt

Configuration

Windows 10 Pro N Build 19045
Python 3.10.8

Command used

"""
Copywrite 2022 - Stephen Wong
Functions to write Excel workbooks with daily analysis.
"""
# Imports
import datetime as dt
import sys

from openpyxl import load_workbook

from azendt_core import (
   sql_fill, file_fill, fill_workbook, read_file, write_file
)

##############################################################################
# fill_market
##############################################################################
def fill_market():
    """
    Fill Market Status workbook. It provides a daily scan of key market,
    interest rate and economic statistics.
    """
    source = "c:\\dropbox\\markets\\Market Status.xlsx"

    # Equities
    sdict = {}
    sdict["Equities"]    = (2, 1, "Markets", "EXEC dbo.reportSecurityGroups 'E'")
    sdict["Volatility"]  = (2, 1, "Markets", "EXEC dbo.reportSecurityGroups 'V'")
    sdict["Vol ETFs"]    = (2, 0, "Markets", "EXEC dbo.reportSecurityGroups 'X'")
    sdict["Commodities"] = (2, 0, "Markets", "EXEC dbo.reportSecurityGroups 'C'")
    sdict["Rates"]       = (2, 1, "Markets", "EXEC dbo.reportSecurityGroups 'R'")
    sdict["Markets"]     = (2, 0, "Markets", "EXEC dbo.reportEcon 'M'")
    sdict["Economics"]   = (2, 0, "Markets", "EXEC dbo.reportEcon 'K'")

    # Update Workbook
    wbook = load_workbook(source)
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print(f'Wrote {source}')
    print(dt.datetime.now(),"\n")

##############################################################################
# fill_new_vol
##############################################################################
def fill_new_vol(year=2023):
    """
    Fill Volatility workbook for current year. Provides in depth information
    about volatility across different markets.
    """
    path = "c:\\dropbox\\markets\\futures"
    # Determine correct date range
    years = {
        2022: "Vol2022.xlsx|01/01/2020|12/31/2022",
        2023: "Vol2023.xlsx|01/01/2021|12/31/2023",
        2024: "Vol2024.xlsx|01/01/2022|12/31/2024",
    }
    # Workbook
    if years.get(year):
        parms = years[year]
        src, sdate, edate = parms.split("|", 2)
        source = f"{path}\\{src}"
    else:
        print("Undefined year.")
        sys.exit()

    # Worksheet Specifications
    sdict = {}
    sdict["Volatility"] = (2, 0, "Markets", f"EXEC dbo.getVolIndices '{sdate}','{edate}'")
    sdict["Vol PX"] = (2, 0, "Markets", f"EXEC dbo.getVolPriceIndex '{sdate}','{edate}'")
    sdict["VRP"] = (2, 0, "Markets", f"EXEC dbo.getVRP '{sdate}','{edate}'")
    sdict["Futures"] = (2, 0, "Markets", f"EXEC Futures.dbo.getVixFutures NULL,'{edate}'")
    sdict["Futures Volume"] = (2, 0, "Markets", "EXEC Futures.dbo.getVixFuturesVolume")
    sdict["Index PX"] = (2, 0, "Markets", f"EXEC dbo.getIndexPX '{sdate}','{edate}'")
    sdict["Single Stock"] = (1, 0, "Markets", f"EXEC dbo.getSinglePriceIndex '{sdate}','{edate}'")
    sdict["UVXY"] = (2, 0, "Markets", f"EXEC dbo.getSecurity 'UVXY','{sdate}','{edate}'")
    sdict["VXX"] = (2, 0, "Markets", f"EXEC dbo.getSecurity 'VXX','{sdate}','{edate}'")
    sdict["SVXY"] = (2, 0, "Markets", f"EXEC dbo.getSecurity 'SVXY','{sdate}','{edate}'")

    # Update workbook
    wbook = load_workbook(source)
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print(f'Wrote {source}')
    print(dt.datetime.now(),"\n")

##############################################################################
# scrub_holdings
##############################################################################
def scrub_holdings():
    """
    Scrub and Splice Fed Treasury Holdings
    """
    fname = "c:\\dropbox\\markets\\rates\\treasuries\\FedHoldings.csv"
    ofile = "c:\\dropbox\\markets\\rates\\treasuries\\fedholdings.txt"

    all_lines = read_file(fname)

    holdings = []
    for line in all_lines[1:]:
        line = line.replace('"',"").replace("'","")
        cols = line.split(",")
        cusip = cols[1].strip()
        stype = cols[2].strip()
        mdate = cols[5].strip()
        amt   = cols[10].strip()
        if stype in ("Bills", "NotesBonds", "FRNs", "TIPS"):
            row = (cusip, stype, mdate, amt)
            newline = "|".join(row)
            holdings.append(newline)
    # Write output
    write_file(holdings, ofile)

##############################################################################
# fill_treasuries
##############################################################################
def fill_treasuries():
    """
    Update Treasury Auctions workbook.
    """
    # pylint: disable=too-many-statements
    source = "c:\\dropbox\\markets\\rates\\Treasury Auctions.xlsx"
    now = dt.datetime.now()
    yyyy = now.year

    # Specifications
    sdict = {}
    sdict["Refinancing"] = (2, 0, "Markets", f"EXEC Markets.dbo.reportRefinancing {yyyy}")
    sdict["Holdings"] = (2, 0, "Markets", "EXEC Markets.dbo.reportHoldings")
    sdict["Weekly"] = (1, 0, "Markets", "EXEC Markets.dbo.reportWeeklyFunding")
    sdict["Monthly"] = (2, 0, "Markets", "EXEC Markets.dbo.reportMonthlyFunding")
    sdict["LT Funding"] = (1, 0, "Markets", "EXEC Markets.dbo.reportLTFunding")
    sdict["ST Funding"] = (1, 0, "Markets", "EXEC Markets.dbo.reportSTFunding")
    sdict["4-Week"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'BILL','4-WEEK'")
    sdict["8-Week"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'BILL','8-WEEK'")
    sdict["13-Week"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'BILL','13-WEEK'")
    sdict["26-Week"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'BILL','26-WEEK'")
    sdict["52-Week"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'BILL','52-WEEK'")
    sdict["2-Year"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'NOTE','2-YEAR'")
    sdict["3-Year"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'NOTE','3-YEAR'")
    sdict["5-Year"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'NOTE','5-YEAR'")
    sdict["7-Year"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'NOTE','7-YEAR'")
    sdict["10-Year"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'NOTE','10-YEAR'")
    sdict["30-Year"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'BOND','30-YEAR'")
    sdict["FRN 1-Yr"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'FRN','1-YEAR'")
    sdict["FRN 2-Yr"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'FRN','2-YEAR'")
    sdict["TIPS 5-Yr"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'TIPS','5-YEAR'")
    sdict["TIPS 10-Yr"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'TIPS','10-YEAR'")
    sdict["TIPS 30-Yr"] = (1, 0, "Markets",  "EXEC Markets.dbo.reportTreasuries 'TIPS','30-YEAR'")
    sdict["CMB"] = (1, 0, "Markets", "EXEC Markets.dbo.reportTreasuries 'CMB','0-WEEK'")

    # Update Workbook
    wbook = load_workbook(source)
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print(f'Wrote {source}')
    print(dt.datetime.now(),"\n")

##############################################################################
# Index Breadth
##############################################################################
def fill_index_breadth():
    """
    Fill Realized Volatility workbook. Indicates breadth of participation
    in market trends for key equity indices.
    """
    source = "c:\\dropbox\\markets\\equities\\Index Breadth.xlsx"

    # Specifications
    sdict = {}
    sdict["SP500"] = (3, 0, "Markets", "EXEC dbo.getIndexStats 'SPX'")
    sdict["NDX"]   = (3, 0, "Markets", "EXEC dbo.getIndexStats 'NDX'")
    sdict["RUI"]   = (3, 0, "Markets", "EXEC dbo.getIndexStats 'RUI'")
    sdict["DJI"]   = (3, 0, "Markets", "EXEC dbo.getIndexStats 'DJI'")

    # Update Workbook
    wbook = load_workbook(source)
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print(f'Wrote {source}')
    print(dt.datetime.now(), "\n")

##############################################################################
# fill_stocks
##############################################################################
def fill_stocks():
    """
    Fill Stock Performance workbook. It provides information about
    the performance of individual stocks in the SPX & NDX indices.
    """
    source = "c:\\dropbox\\markets\\equities\\Stock Performance.xlsx"

    # Specifications
    sdict = {}
    sdict["All"] = (1, 0, "Markets", "EXEC dbo.getStockPerformance")
    sdict["SPX"] = (1, 0, "Markets", "EXEC dbo.getStockPerformance 'SPX'")
    sdict["NDX"] = (1, 0, "Markets", "EXEC dbo.getStockPerformance 'NDX'")

    # Update Workbook
    wbook = load_workbook(source)
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print(f'Wrote {source}')
    print(dt.datetime.now(), "\n")

##############################################################################
# fill_weekly
##############################################################################
def fill_weekly():
    """
    Fill Weekly Analysis workbook. Provides weekly snapshots about the
    price performance and volatility of key equity indices.
    """
    ##########################################################################
    # Helper function
    def fill_sheet(ticker):
        """ Helper function to fill weekly worksheet """
        target = wbook[ticker]
        sql = f"EXEC dbo.WeeklyAnalysis '{ticker}', 1"
        sql_fill("CME", sql, target, 2, 0)

        sql = f"EXEC dbo.WeeklyAnalysis '{ticker}', 0"
        sql_fill("CME", sql, target, 2, 9)

    def fill_mosheet(ticker):
        """ Helper function to fill monthly worksheet """
        target = wbook[f"{ticker}-Mo"]
        sql = f"EXEC dbo.MonthlyAnalysis '{ticker}'"
        sql_fill("CME", sql, target, 1, 0)
    ##########################################################################
    # Workbook
    source = "c:\\dropbox\\markets\\futures\\Weekly Analysis.xlsx"
    wbook = load_workbook(source)
    sheets = ["eNDX", "eSPX", "NDX", "SP500", "RUT", "VIX"]

    # Fill weekly and monthly worksheets
    for ticker in sheets:
        fill_sheet(ticker)
        fill_mosheet(ticker)

    # Finished
    wbook.save(source)
    wbook.close()
    print(f'Wrote {source}')
    print(dt.datetime.now(), "\n")

##############################################################################
# Realized Volatility
##############################################################################
def fill_realized_vol():
    """
    Fill Realized Volatility workbook. Provides info on the actual
    volatility of key equity indices.
    """
    source = "c:\\dropbox\\markets\\volatility\\Realized Volatility.xlsx"

    # Define specifications to fill each worksheet
    sdict = {}
    sdict["Current"] = (1, 0, "Markets", "EXEC dbo.getRealizedVolByWk")
    sdict["Annual"]  = (1, 0, "Markets", "EXEC dbo.getRealizedVolByYr")
    sdict["Moves"]   = (1, 0, "Markets", "EXEC dbo.getBigMoves")
    sdict["SP500"]   = (1, 0, "Markets", "EXEC dbo.getIndexHistogram 'SP500'")
    sdict["NDX"]     = (1, 0, "Markets", "EXEC dbo.getIndexHistogram 'NDX'")
    sdict["RUT"]     = (1, 0, "Markets", "EXEC dbo.getIndexHistogram 'RUT'")

    # Load workbook
    wbook = load_workbook(source)

    # Update Workbook
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print("Wrote", source)
    print(dt.datetime.now(), "\n")

##############################################################################
# fill_implied_vol
##############################################################################
def fill_implied_vol():
    """
    Fill Implied Volatility workbook. Displays a histogram of implied
    volatility for VIX and RDAVG.
    """
    source = "c:\\dropbox\\markets\\volatility\\Implied Volatility.xlsx"

    # Specifications
    sdict = {}
    sdict["Monthly"] = (2, 0,  "Markets", "EXEC dbo.getVolMonthly 'VIX'")
    sdict["Monthly"] = (2, 7,  "Markets", "EXEC dbo.getVolMonthly 'RDAVG'")
    sdict["Monthly"] = (2, 21, "Markets", "EXEC dbo.getVolMonthly 'VVIX'")
    sdict["Monthly"] = (2, 28, "Markets", "EXEC dbo.getVolMonthly 'SKEW'")
    sdict["Monthly"] = (2, 35, "Markets", "EXEC dbo.getVolMonthly 'VULN'")
    sdict["Weekly"] = (2, 0,  "Markets", "EXEC dbo.getVolWeekly 'VIX'")
    sdict["Weekly"] = (2, 7,  "Markets", "EXEC dbo.getVolWeekly 'RDAVG'")
    sdict["Weekly"] = (2, 21, "Markets", "EXEC dbo.getVolWeekly 'VVIX'")
    sdict["Weekly"] = (2, 28, "Markets", "EXEC dbo.getVolWeekly 'SKEW'")
    sdict["Weekly"] = (2, 35, "Markets", "EXEC dbo.getVolWeekly 'VULN'")
    sdict["VIX"] = (1, 0, "Markets", "EXEC dbo.getVolHistogram 'VIX'")
    sdict["RDAVG"] = (1, 0, "Markets", "EXEC dbo.getVolHistogram 'RDAVG'")

    # Load Workbook
    wbook = load_workbook(source)

    # Update Workbook
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print("Wrote", source)
    print(dt.datetime.now(), "\n")

##############################################################################
# fill_sigma
##############################################################################
def fill_sigma():
    """
    Fill Sigma Analysis workbook. Provides historical analysis of large
    moves for key indices.
    """
    source = "c:\\dropbox\\markets\\volatility\\Sigma Analysis.xlsx"

    # Specifications
    sdict = {}
    sdict["SP500"] = (2, 0, "Markets", "EXEC dbo.analyzeSigma 'SP500'")
    sdict["SP500"] = (2, 9, "Markets", "EXEC dbo.analyzeSigmaRecovery 'SP500'")
    sdict["NDX"]   = (2, 0, "Markets", "EXEC dbo.analyzeSigma 'NDX'")
    sdict["NDX"]   = (2, 9, "Markets", "EXEC dbo.analyzeSigmaRecovery 'NDX'")
    sdict["RUT"]   = (2, 0, "Markets", "EXEC dbo.analyzeSigma 'RUT'")
    sdict["RUT"]   = (2, 9, "Markets", "EXEC dbo.analyzeSigmaRecovery 'RUT'")
    sdict["VIX"]   = (2, 0, "Markets", "EXEC dbo.analyzeSigma 'VIX'")
    sdict["VIX"]   = (2, 9, "Markets", "EXEC dbo.analyzeSigmaRecovery 'VIX'")
    sdict["RDAVG"] = (2, 0, "Markets", "EXEC dbo.analyzeSigma 'RDAVG'")
    sdict["RDAVG"] = (2, 9, "Markets", "EXEC dbo.analyzeSigmaRecovery 'RDAVG'")

    # Load Workbook
    wbook = load_workbook(source)

    # Update Workbook
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print("Wrote", source)
    print(dt.datetime.now(), "\n")

##############################################################################
# fill_mavg
##############################################################################
def fill_mavg():
    """
    Update mavgSPX workbook. Provides historical data for the 50, 100
    and 200 day moving average for SPX index.
    """
    source = "c:\\dropbox\\markets\\mavgSPX.xlsx"

    # Specifications
    sdict = {}
    sdict["50"]  = (1, 0, "Markets", "EXEC dbo.getMAVG_Stats 50")
    sdict["100"] = (1, 0, "Markets", "EXEC dbo.getMAVG_Stats 100")
    sdict["200"] = (1, 0, "Markets", "EXEC dbo.getMAVG_Stats 200")

    # Load Workbook
    wbook = load_workbook(source)

    # Update Workbook
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print("Wrote", source)
    print(dt.datetime.now(),"\n")

##############################################################################
# fill_index_histogram
##############################################################################
def fill_index_histogram():
    """
    Fill Index Histograms workbook. Displays performance information
    in a histogram for key equity indices.
    """
    source = "c:\\dropbox\\markets\\options\\Index Histograms.xlsx"

    # Specifications
    sdict = {}
    sdict["SPX"]  = (1, 0, "Markets", "EXEC dbo.getIndexHistogram 'SP500'")
    sdict["NDX"]  = (1, 0, "Markets", "EXEC dbo.getIndexHistogram 'NDX'")
    sdict["RUT"]  = (1, 0, "Markets", "EXEC dbo.getIndexHistogram 'RUT'")

    # Load Workbook
    wbook = load_workbook(source)

    # Update Workbook
    fill_workbook(wbook, sdict)

    # Finished
    wbook.save(source)
    wbook.close()
    print("Wrote", source)
    print(dt.datetime.now(), "\n")

##############################################################################
# fill_cot:
##############################################################################
def fill_cot():
    """
    Fills eMini Positions workbook with data downloaded from CFTC.
    """
    # pylint: disable=too-many-statements
    source = "c:\\dropbox\\markets\\futures\\eMini Positions.xlsx"

    # Specifications
    sdict = {}
    sdict["SPX"]  = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'SPX'")
    sdict["NDX"]  = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'NDX'")
    sdict["RUT"]  = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'RUT'")
    sdict["DJI"]  = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'DJI'")
    sdict["VIX"]  = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'VIX'")
    sdict["TB30"] = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'TB30'")
    sdict["TN10"] = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'TN10'")
    sdict["TN05"] = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'TN05'")
    sdict["TN02"] = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'TN02'")
    sdict["FF30"] = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'FF30'")
    sdict["Eurodollars"] = (2, 0, "Futures", "EXEC dbo.fillCFTC_sheet 'Eurodollars'")

    # Load Workbook
    wbook = load_workbook(source)

    # Update Workbook
    fill_workbook(wbook, sdict)

    # Finished
    print(f"Wrote {source}")
    wbook.save(source)
    wbook.close()

##############################################################################
# fill_put_stats
##############################################################################
def fill_put_stats(idx):
    """
    Fill Put Stats workbooks for the SPX/NDX indices. Performs
    sensitivity analysis on how Greeks vary depending on ITM probability
    and days to expiry.
    """
    ##########################################################################
    # Helper function to read data into list
    def process_stats(fname):
        # Read datafile and create list
        all_lines = read_file(fname)
        all_lines.sort(reverse=True)

        allrows = []
        for line in all_lines:
            row = line.split("|")
            row = [float(col) for col in row]
            allrows.append(row)
        return allrows
    ##########################################################################
    if idx.upper() == "N":
        file   = "c:\\dropbox\\markets\\options\\csidata\\putNDXstats"
        source = "c:\\dropbox\\markets\\options\\csidata\\NDX Put Stats.xlsx"
    elif idx.upper() == "S":
        file   = "c:\\dropbox\\markets\\options\\csidata\\putSPXstats"
        source = "c:\\dropbox\\markets\\options\\csidata\\SPX Put Stats.xlsx"
    elif idx.upper() == "V":
        file   = "c:\\dropbox\\markets\\options\\vix\\putSPXstats"
        source = "c:\\dropbox\\markets\\options\\vix\\VIX Put Stats.xlsx"

    # Update workbook
    wbook = load_workbook(source)

    # 2023
    target = wbook["2023"]
    fname = f"{file}2023.txt"
    allrows = process_stats(fname)
    file_fill(allrows, target, 2, 0)

    # 2022
    target = wbook["2022"]
    fname = f"{file}2022.txt"
    allrows = process_stats(fname)
    file_fill(allrows, target, 2, 0)

    # 2021
    target = wbook["2021"]
    fname = f"{file}2021.txt"
    allrows = process_stats(fname)
    file_fill(allrows, target, 2, 0)

    # 2020
    target = wbook["2020"]
    fname = f"{file}2020.txt"
    allrows = process_stats(fname)
    file_fill(allrows, target, 2, 0)

    # 2019
    target = wbook["2019"]
    fname = f"{file}2019.txt"
    allrows = process_stats(fname)
    file_fill(allrows, target, 2, 0)

    # Finished
    wbook.save(source)
    wbook.close()
    print("Wrote", source)
    print(dt.datetime.now(),"\n")

##############################################################################
# fill_stats()
##############################################################################
def fill_stats():
    """
    Updates the Statistical Analysis workbook. Provides information
    about which stocks exhibit stationarity and the correlation in
    price movement between pairs of stocks.
    """
    source = "c:\\dropbox\\markets\\equities\\Statistical Analysis.xlsx"
    cfile  = "c:\\dropbox\\markets\\equities\\pairCorr.txt"
    afile  = "c:\\dropbox\\markets\\equities\\allADFuller.txt"

    wbook = load_workbook(source)

    ##########################################################################
    # Pair Correlation
    ##########################################################################
    target = wbook["Pairs"]
    rskip  = 1

    # Read input file and paste into worksheet
    all_lines = read_file(cfile)
    for row_ctr,line in enumerate(all_lines,rskip+1):
        cols = line.split("|")
        tick_a = cols[0].strip()
        tick_b = cols[1].strip()
        method = cols[2].strip()
        obs    = cols[3].strip()
        corr   = cols[4].strip()
        pval   = cols[5].strip()

        if obs:
            obs = int(obs)
        if corr:
            corr = round(float(corr),4)
        if pval:
            pval = round(float(pval),4)

        target.cell(row=row_ctr, column=1).value = tick_a
        target.cell(row=row_ctr, column=2).value = tick_b
        target.cell(row=row_ctr, column=3).value = method
        target.cell(row=row_ctr, column=4).value = obs
        target.cell(row=row_ctr, column=5).value = corr
        target.cell(row=row_ctr, column=6).value = pval

    ##########################################################################
    # ADFuller
    ##########################################################################
    target = wbook["ADFuller"]
    rskip  = 1

    # Read input file and paste into worksheet
    all_lines = read_file(afile)
    for row_ctr,line in enumerate(all_lines,rskip+1):
        cols = line.split("|")
        tick_a = cols[0].strip()
        maxlag = cols[1].strip()
        obs    = cols[2].strip()
        tstat  = cols[3].strip()
        pval   = cols[4].strip()
        crit1  = cols[5].strip()
        crit5  = cols[6].strip()

        if maxlag:
            maxlag = int(maxlag)
        if obs:
            obs = int(obs)
        if tstat:
            tstat = round(float(tstat),4)
        if pval:
            pval = round(float(pval),4)
        if crit1:
            crit1 = round(float(crit1),4)
        if crit5:
            crit5 = round(float(crit5),4)

        target.cell(row=row_ctr, column=1).value = tick_a
        target.cell(row=row_ctr, column=2).value = maxlag
        target.cell(row=row_ctr, column=3).value = obs
        target.cell(row=row_ctr, column=4).value = tstat
        target.cell(row=row_ctr, column=5).value = pval
        target.cell(row=row_ctr, column=6).value = crit1
        target.cell(row=row_ctr, column=7).value = crit5

    ##########################################################################
    # Ticker
    ##########################################################################
    target = wbook["Ticker"]
    sql = "EXEC dbo.analyzeSecurityCorrelation"
    sql_fill("Markets", sql, target, 2, 0)

    # Finished
    wbook.save(source)
    wbook.close()
    print("Wrote", source)
    print(dt.datetime.now(),"\n")

##############################################################################
# write_main
##############################################################################
def write_main(weekly=0):
    """
    Wrapper function to write all reports
    """
    print("Started at", dt.datetime.now(), "\n")
    fill_market()
    fill_weekly()
    fill_index_breadth()
    fill_stocks()
    fill_new_vol()
    fill_realized_vol()
    fill_implied_vol()
    fill_sigma()
    fill_index_histogram()
    fill_put_stats('N')
    fill_put_stats('S')
    fill_treasuries()
    if weekly == 1:
        fill_cot()
        fill_stats()

Pylint output

pylint crashed with a ``AstroidError`` and with the following stacktrace:

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\pylint\lint\pylinter.py", line 790, in _lint_file
    check_astroid_module(module)
  File "C:\Python310\lib\site-packages\pylint\lint\pylinter.py", line 1060, in check_astroid_module
    retval = self._check_astroid_module(
  File "C:\Python310\lib\site-packages\pylint\lint\pylinter.py", line 1110, in _check_astroid_module
    walker.walk(node)
  File "C:\Python310\lib\site-packages\pylint\utils\ast_walker.py", line 93, in walk
    self.walk(child)
  File "C:\Python310\lib\site-packages\pylint\utils\ast_walker.py", line 93, in walk
    self.walk(child)
  File "C:\Python310\lib\site-packages\pylint\utils\ast_walker.py", line 90, in walk
    callback(astroid)
  File "C:\Python310\lib\site-packages\pylint\checkers\refactoring\refactoring_checker.py", line 682, in visit_for
    self._check_unnecessary_list_index_lookup(node)
  File "C:\Python310\lib\site-packages\pylint\checkers\refactoring\refactoring_checker.py", line 2118, in _check_unnecessary_list_index_lookup
    has_start_arg, confidence = self._enumerate_with_start(node)
  File "C:\Python310\lib\site-packages\pylint\checkers\refactoring\refactoring_checker.py", line 2236, in _enumerate_with_start
    start_val, confidence = self._get_start_value(start_arg)
  File "C:\Python310\lib\site-packages\pylint\checkers\refactoring\refactoring_checker.py", line 2260, in _get_start_value
    start_val = node.value
AttributeError: 'BinOp' object has no attribute 'value'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\pylint\lint\pylinter.py", line 755, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File "C:\Python310\lib\site-packages\pylint\lint\pylinter.py", line 792, in _lint_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError

### Expected behavior

Normal pylint error messages and scoring.

### Pylint version

```shell
pylint 2.15.10
astroid 2.3.12
Python 3.10.8

OS / Environment

Windows 10 Pro N Build 19045

Additional dependencies

No response

Pierre-Sassoulas commented 1 year ago

This has been fixed in 2.16.0b0, please upgrade to the beta version. We could not release this hotfix in 2.15.10 because of a cherry-pick issue. We're also going to release 2.16.0 tomorrow unless there's an issue in 2.16.0b0 that is signaled before that.

swong59 commented 1 year ago

Thanks, I will grab 2.16.0 tomorrow. Appreciate the immediate response.

allanlewis commented 1 year ago

2.16.0 hasn't been released yet and I'm seeing this issue with one of my files. Is there no possibility of backporting it to 2.15.x in the meantime?

Pierre-Sassoulas commented 1 year ago

You can use the beta version by asking pip for 2.16.0b1.

allanlewis commented 1 year ago

You can use the beta version by asking pip for 2.16.0b1.

Sure, but then I'll probably have more messages to deal with 😜

I've pinned my project to 2.15.5 for now as I don't see the error with that version.

Pierre-Sassoulas commented 1 year ago

We're not going to release another version for 2.15.x sorry. Maybe if someone does the cherry-pick and open a PR for it, but 2.16.0 is coming out soon and we're not going to maintain 2.15 anymore when it's out anyway.

allanlewis commented 1 year ago

That's ok - I can stick with the working version for now, I've no desire to use a beta version 🙂