Skip to content

Commit

Permalink
manual ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyheppell committed Jul 2, 2024
1 parent cf719a1 commit 87fff65
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ ignore = [
]

[tool.ruff.lint.per-file-ignores]
"**/tests/*" = ["D103"] # Ignore method docstring errors in tests
"**/tests/*" = [
"D103", # Ignore method docstring errors in tests
"PD901", # Allow `df` variable name in tests
]

[tool.ruff.lint.pydocstyle]
convention = "google"
Expand Down
6 changes: 3 additions & 3 deletions src/extractor/extractors/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ def _remove_nan(value: Any) -> Any:
Returns:
The value with NA and NaN replaced.
"""
if type(value) == dict:
if isinstance(value, dict):
for dkey, dvalue in value.items():
value[dkey] = _remove_nan(dvalue)
elif type(value) == list:
elif isinstance(value, list):
for i, item in enumerate(value):
value[i] = _remove_nan(item)
elif type(value) == float and np.isnan(value):
elif isinstance(value, float) and np.isnan(value):
value = None
elif value is pd.NA:
value = None
Expand Down
2 changes: 1 addition & 1 deletion src/extractor/extractors/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def load_posts(
# Get the "url" property if there is an image
posts_df["og_image_url"] = posts_df["yoast_head_json.og_image"].apply(
lambda image: image[0]["url"]
if type(image) != float and len(image) > 0
if not isinstance(image, float) and len(image) > 0
else None
)

Expand Down
5 changes: 3 additions & 2 deletions src/extractor/parse/translations/_pickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ def add_translation(self, href: str, lang: str) -> None:


class Polylang(LangPicker):
"""Language picker from the plugin \
`Polylang <https://wordpress.org/plugins/polylang/>`.
"""Language picker from the plugin Polylang.
`WordPress plugin page <https://wordpress.org/plugins/polylang/>`.
Has the structure::
Expand Down
4 changes: 2 additions & 2 deletions tests/extractors/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def media_df(media_df_and_registry):

def test_media_times(media_df):
media_1 = media_df.loc[1]
assert type(media_1.date_gmt) == pd.Timestamp
assert type(media_1.modified_gmt) == pd.Timestamp
assert isinstance(media_1.date_gmt, pd.Timestamp)
assert isinstance(media_1.modified_gmt, pd.Timestamp)

assert media_1.date_gmt.tzinfo is None, "date_gmt had timezone information"
assert media_1.modified_gmt.tzinfo is None, "modified_gmt had timezone information"
Expand Down
4 changes: 2 additions & 2 deletions tests/extractors/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_equals_expected(datadir, pages_df):

def test_post_times(pages_df):
post_1 = pages_df.loc[1]
assert type(post_1.date_gmt) == pd.Timestamp
assert type(post_1.modified_gmt) == pd.Timestamp
assert isinstance(post_1.date_gmt, pd.Timestamp)
assert isinstance(post_1.modified_gmt, pd.Timestamp)

assert post_1.date_gmt.tzinfo is None, "date_gmt had timezone information"
assert post_1.modified_gmt.tzinfo is None, "modified_gmt had timezone information"
Expand Down
6 changes: 3 additions & 3 deletions tests/extractors/test_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def posts_df(posts_df_and_registry):

def test_post_times(posts_df):
post_1 = posts_df.loc[1]
assert type(post_1.date_gmt) == pd.Timestamp
assert type(post_1.modified_gmt) == pd.Timestamp
assert isinstance(post_1.date_gmt, pd.Timestamp)
assert isinstance(post_1.modified_gmt, pd.Timestamp)

assert post_1.date_gmt.tzinfo is None, "date_gmt had timezone information"
assert post_1.modified_gmt.tzinfo is None, "modified_gmt had timezone information"
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_translations_bidirectional(posts_df_and_registry):
posts_df, registry = posts_df_and_registry
posts_df = resolve_post_translations(registry, posts_df)
# Currently 1 <-> 2, let's remove 1 <- 2
posts_df.at[2, "translations"] = []
posts_df.loc[2, "translations"] = []

posts_df = ensure_translations_undirected(posts_df)

Expand Down

0 comments on commit 87fff65

Please sign in to comment.