Skip to content

Commit f8fae20

Browse files
authored
TYP: mypy upgrade (#188) (#1109)
Co-authored-by: Mike Lync <[email protected]>
1 parent 64a7015 commit f8fae20

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

python/rateslib/_spec_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _map_true_false(v: str) -> bool | None:
4141
# TODO (low): clean this up when setting a minimum pandas version at 2.1.0
4242
df[df["dtype"] == "bool"] = df[df["dtype"] == "bool"].map(_map_true_false)
4343
else:
44-
df[df["dtype"] == "bool"] = df[df["dtype"] == "bool"].applymap(_map_true_false) # type: ignore[operator]
44+
df[df["dtype"] == "bool"] = df[df["dtype"] == "bool"].applymap(_map_true_false) # type: ignore[operator, index]
4545
return df
4646

4747
path = "data/__instrument_spec.csv"

python/rateslib/data/fixings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ def __init__(
933933
self._accrual_end = accrual_end
934934
self._fixing_method = _get_float_fixing_method(fixing_method)
935935
self._method_param = method_param
936-
self._populated = Series(index=[], data=[], dtype=float)
936+
self._populated = Series(index=[], data=[], dtype=float) # type: ignore[assignment]
937937

938938
@property
939939
def fixing_method(self) -> FloatFixingMethod:

python/rateslib/fx_volatility/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def _validate_weights(
510510
w[s:e] = ( # type: ignore[misc]
511511
w[s:e] * days / w[s:e].sum() # type: ignore[misc]
512512
) # scale the weights to allocate the correct time between nodes.
513-
w[eval_date] = 0.0
513+
w[eval_date] = 0.0 # type: ignore[call-overload]
514514
return w
515515

516516

python/rateslib/instruments/bonds/bond_future.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -559,20 +559,20 @@ def dlv(
559559
],
560560
index=range(len(basket)),
561561
)
562-
df["Price"] = prices
563-
df["YTM"] = [bond.ytm(prices[i], settlement, dirty=dirty) for i, bond in enumerate(basket)]
564-
df["C.Factor"] = self.cfs
565-
df["Gross Basis"] = self.gross_basis(future_price, prices, settlement, dirty=dirty)
566-
df["Implied Repo"] = self.implied_repo(
562+
df["Price"] = prices # type: ignore[assignment]
563+
df["YTM"] = [bond.ytm(prices[i], settlement, dirty=dirty) for i, bond in enumerate(basket)] # type: ignore[assignment]
564+
df["C.Factor"] = self.cfs # type: ignore[assignment]
565+
df["Gross Basis"] = self.gross_basis(future_price, prices, settlement, dirty=dirty) # type: ignore[assignment]
566+
df["Implied Repo"] = self.implied_repo( # type: ignore[assignment]
567567
future_price,
568568
prices,
569569
settlement,
570570
delivery,
571571
convention,
572572
dirty=dirty,
573573
)
574-
df["Actual Repo"] = r_
575-
df["Net Basis"] = self.net_basis(
574+
df["Actual Repo"] = r_ # type: ignore[assignment]
575+
df["Net Basis"] = self.net_basis( # type: ignore[assignment]
576576
future_price,
577577
prices,
578578
r_,

python/rateslib/solver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ def delta(
17471747
df.loc[indexes[key[0]], (key[1], key[2])] = array
17481748

17491749
if not isinstance(base, NoInput):
1750-
df.loc[r_idx, ("all", base)] = df.loc[r_idx, (slice(None), base)].sum(axis=1) # type: ignore[index]
1750+
df.loc[r_idx, ("all", base)] = df.loc[r_idx, (slice(None), base)].sum(axis=1)
17511751

17521752
sorted_cols = df.columns.sort_values()
17531753
ret: DataFrame = df.loc[:, sorted_cols].astype("float64")
@@ -2291,7 +2291,7 @@ def exo_delta(
22912291
df.loc[indexes[key[0]], (key[1], key[2])] = array
22922292

22932293
if not isinstance(base, NoInput):
2294-
df.loc[r_idx, ("all", base)] = df.loc[r_idx, (slice(None), base)].sum(axis=1) # type: ignore[index]
2294+
df.loc[r_idx, ("all", base)] = df.loc[r_idx, (slice(None), base)].sum(axis=1)
22952295

22962296
sorted_cols = df.columns.sort_values()
22972297
_: DataFrame = df.loc[:, sorted_cols].astype("float64")

0 commit comments

Comments
 (0)