Skip to content

Commit

Permalink
STY: ruff check pandas, pyupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Jan 6, 2025
1 parent f5dc107 commit 0391f28
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
13 changes: 10 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ match = '(?!(test_|_)).*\.py'

[tool.ruff]
line-length = 88
exclude = ["version.py"]
exclude = ["version.py", "docs/ext/**"]

[tool.ruff.lint]
ignore = [
"B028", # No explicit `stacklevel` keyword argument found
"C901", # mccabe complex-structure
"PD901", # Avoid using the generic variable name `df` for dataframes
"PD011", # Avoid using .values on dataframes (gives false positives)
]
select = [
"B", # flake-8-bugbear
Expand All @@ -116,7 +118,7 @@ select = [
"F", # pyflakes
"I", # isort
"NPY", # numpy
# "PD", # pandas-vet
"PD", # pandas-vet
"PIE", # flake8-pie
# "PL", # pylint
"Q", # flake8-quotes
Expand All @@ -125,13 +127,18 @@ select = [
"SIM", # flake8-simplify
# "TCH", # flake8-type-checking
# "TID", # flake8-tidy-imports
# "UP", # pyupgrade
"UP", # pyupgrade
"W", # pylint-warnings
]

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
# TODO: Remove when Python 3.8 / 3.9 support is deprecated.
keep-runtime-typing = true

[tool.ruff.lint.isort]
combine-as-imports = true

Expand Down
3 changes: 2 additions & 1 deletion src/fmu/dataio/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def export_file(
if isinstance(out, xtgeo.Polygons):
# out.pname = "ID" not working
out.get_dataframe(copy=False).rename(
columns={out.pname: "ID"}, inplace=True
columns={out.pname: "ID"},
inplace=True, # noqa: PD002
)
out.get_dataframe(copy=False).to_csv(file, index=False)
elif file_suffix == ".pol" and isinstance(obj, (xtgeo.Polygons, xtgeo.Points)):
Expand Down
8 changes: 3 additions & 5 deletions src/fmu/dataio/export/rms/inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,9 @@ def _get_table_from_rms(self) -> pd.DataFrame:
"""Fetch volumetric table from RMS and convert to pandas dataframe"""
_logger.debug("Read values and convert to pandas dataframe...")
return pd.DataFrame.from_dict(
(
self.project.volumetric_tables[self._volume_table_name]
.get_data_table()
.to_dict()
)
self.project.volumetric_tables[self._volume_table_name]
.get_data_table()
.to_dict()
)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion src/fmu/dataio/providers/_filedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _get_filestem(self) -> str:
self._get_timepart_for_filename(),
)
# join non-empty parts with '--'
filestem = "--".join((p for p in filestem_order if p))
filestem = "--".join(p for p in filestem_order if p)
filestem = self._sanitize_the_filestem(filestem)
return filestem.lower()

Expand Down

0 comments on commit 0391f28

Please sign in to comment.