-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lint workflow to run pre-commit on all files #545
Changes from all commits
c5f857a
485da34
19bd712
13730c2
619b5bd
36078a7
c64580a
29ddd2f
008cb0a
976ff32
f968f2c
9bcf19e
bba48a7
1f00b25
6f62893
194ed9e
e89fa6e
a560f2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: lint | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
cache: 'pip' | ||
cache-dependency-path: '**/**.txt' | ||
- uses: pre-commit/action@v2.0.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
# polyfill cached_property for python <= 3.7 (using lru_cache which was introduced in python3.2) | ||
from functools import lru_cache | ||
|
||
cached_property = lambda func: property(lru_cache()(func)) # noqa | ||
cached_property = lambda func: property(lru_cache()(func)) # type: ignore # noqa | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mypy throws errors about assigning to types here:
|
||
|
||
import betterproto # noqa | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
[mypy] | ||
python_version = 3.7 | ||
python_version = 3.8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updating python version to 3.8 now that we have a min version of 3.8 |
||
warn_unused_configs = True | ||
exclude = versioneer.py | ||
ignore_missing_imports = True | ||
show_traceback = True | ||
strict_optional = False | ||
|
||
[mypy-cloudpickle.*] | ||
ignore_missing_imports = True | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
check-manifest | ||
black==20.8b1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are now configured only in |
||
flake8 | ||
isort | ||
bandit | ||
mypy==0.971 | ||
codespell | ||
click<8.1.0 | ||
bandit |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ tag_prefix = v | |
parentdir_prefix = transformers4rec- | ||
|
||
[codespell] | ||
skip = .*pb2.py,./.git,./.github,./.mypy_cache,./dist,./build,./docs/build,.*egg-info.*,versioneer.py,*.csv,*.parquet | ||
skip = .*pb2.py,.git/*,.github/*,./.mypy_cache,./dist,./build,./docs/build,.*egg-info.*,versioneer.py,*.csv,*.parquet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ignore-words = ./ci/ignore_codespell_words.txt | ||
count = | ||
quiet-level = 3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,7 @@ | |
import pytest | ||
|
||
from merlin_standard_lib import ColumnSchema, Schema, Tag | ||
from transformers4rec.data.preprocessing import ( | ||
add_item_first_seen_col_to_df, | ||
remove_consecutive_interactions, | ||
) | ||
from transformers4rec.data import preprocessing | ||
from transformers4rec.data.synthetic import ( | ||
generate_item_interactions, | ||
synthetic_ecommerce_data_schema, | ||
|
@@ -21,7 +18,7 @@ def test_remove_consecutive_interactions(): | |
schema += Schema([ColumnSchema.create_continuous("timestamp", tags=[Tag.SESSION])]) | ||
|
||
interactions_df = generate_item_interactions(500, schema) | ||
filtered_df = remove_consecutive_interactions(interactions_df.copy()) | ||
filtered_df = preprocessing.remove_consecutive_interactions(interactions_df.copy()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my was throwing an error about the module not having the attribute with the function import version (not sure I fully understand why). But this seems to work without error:
|
||
|
||
assert len(filtered_df) < len(interactions_df) | ||
assert len(filtered_df) == 499 | ||
|
@@ -32,7 +29,7 @@ def test_add_item_first_seen_col_to_df(): | |
schema = synthetic_ecommerce_data_schema.remove_by_name("item_recency") | ||
schema += Schema([ColumnSchema.create_continuous("timestamp", tags=[Tag.SESSION])]) | ||
|
||
df = add_item_first_seen_col_to_df(generate_item_interactions(500, schema)) | ||
df = preprocessing.add_item_first_seen_col_to_df(generate_item_interactions(500, schema)) | ||
|
||
assert len(list(df.columns)) == len(schema) + 1 | ||
assert isinstance(df["item_ts_first"], pd.Series) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rest of these args have moved to
mypy.ini