Skip to content

Commit f1b822f

Browse files
authored
Merge pull request #11 from mloncode/linting
Add linting tools
2 parents 394388a + 9750ac6 commit f1b822f

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

.flake8

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
ignore=B008,E121,E123,E126,E203,E226,E24,E704,W503,W504,D100,D105,D200,D202,D301,D402,D
3+
max-line-length=88
4+
exclude=
5+
.git
6+
import-order-style=appnexus
7+
application-package-names=data_generators
8+
per-file-ignores=
9+
**/tests/*:D
10+
**/test*.py:D

.pylintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[MASTER]
2+
jobs=0
3+
load-plugins=pylint.extensions.docparams
4+
5+
[MESSAGES CONTROL]
6+
disable=all
7+
enable=missing-param-doc,
8+
differing-param-doc,
9+
differing-type-doc,
10+
missing-return-doc

conf/requirements-dev.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
flake8
2+
flake8-bugbear
3+
flake8-docstrings
4+
flake8-import-order
5+
pylint
6+
mypy
7+
black

mypy.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[mypy]
2+
disallow_untyped_defs = True
3+
ignore_missing_imports = True
4+
strict_optional = False

notebooks/codesearchnet-opennmt.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
from argparse import ArgumentParser
1+
from argparse import ArgumentParser, Namespace
22
import logging
33
from pathlib import Path
44
from time import time
5-
from typing import List
5+
from typing import List, Tuple
66

77
import pandas as pd
8+
from torch.utils.data import Dataset
89

910

1011
logging.basicConfig(level=logging.INFO)
1112

1213

13-
class CodeSearchNetRAM(object):
14+
class CodeSearchNetRAM(Dataset):
1415
"""Stores one split of CodeSearchNet data in memory
1516
1617
Usage example:
@@ -50,7 +51,7 @@ def _jsonl_list_to_dataframe(
5051
sort=False,
5152
)
5253

53-
def __getitem__(self, idx: int):
54+
def __getitem__(self, idx: int) -> Tuple[str, str]:
5455
row = self.pd.iloc[idx]
5556

5657
# drop class name
@@ -65,11 +66,11 @@ def __getitem__(self, idx: int):
6566
# fn_body_enc = self.enc.encode(fn_body)
6667
return (fn_name, fn_body)
6768

68-
def __len__(self):
69+
def __len__(self) -> int:
6970
return len(self.pd)
7071

7172

72-
def main(args):
73+
def main(args: Namespace) -> None:
7374
dataset = CodeSearchNetRAM(Path(args.data_dir), args.newline)
7475
split_name = Path(args.data_dir).name
7576
with open(args.src_file % split_name, mode="w", encoding="utf8") as s, open(

0 commit comments

Comments
 (0)