diff --git a/fairseq/__init__.py b/fairseq/__init__.py index 4123fcd6f..c5d4b5607 100644 --- a/fairseq/__init__.py +++ b/fairseq/__init__.py @@ -7,3 +7,5 @@ # from .multiprocessing_pdb import pdb + +__all__ = ['pdb'] diff --git a/fairseq/bleu.py b/fairseq/bleu.py index 13a3bf507..3aec86738 100644 --- a/fairseq/bleu.py +++ b/fairseq/bleu.py @@ -97,7 +97,7 @@ class Scorer(object): def result_string(self, order=4): assert order <= 4, "BLEU scores for order > 4 aren't supported" fmt = 'BLEU{} = {:2.2f}, {:2.1f}' - for i in range(1, order): + for _ in range(1, order): fmt += '/{:2.1f}' fmt += ' (BP={:.3f}, ratio={:.3f}, syslen={}, reflen={})' bleup = [p * 100 for p in self.precision()[:order]] diff --git a/fairseq/data.py b/fairseq/data.py index 135648998..baf42bbc8 100644 --- a/fairseq/data.py +++ b/fairseq/data.py @@ -326,7 +326,7 @@ def shuffled_batches_by_size(src, dst, max_tokens=None, epoch=1, sample=0, max_p batches = result else: - for i in range(epoch - 1): + for _ in range(epoch - 1): np.random.shuffle(batches) return batches diff --git a/fairseq/sequence_generator.py b/fairseq/sequence_generator.py index e568f2de2..ba284ee11 100644 --- a/fairseq/sequence_generator.py +++ b/fairseq/sequence_generator.py @@ -126,7 +126,7 @@ class SequenceGenerator(object): # helper function for allocating buffers on the fly buffers = {} - def buffer(name, type_of=tokens): + def buffer(name, type_of=tokens): # noqa if name not in buffers: buffers[name] = type_of.new() return buffers[name] diff --git a/fairseq/utils.py b/fairseq/utils.py index 37bbc9e1d..07225f36e 100644 --- a/fairseq/utils.py +++ b/fairseq/utils.py @@ -41,7 +41,7 @@ def torch_persistent_save(*args, **kwargs): for i in range(3): try: return torch.save(*args, **kwargs) - except: + except Exception: if i == 2: logging.error(traceback.format_exc()) diff --git a/generate.py b/generate.py index af490c4fa..91efd7d13 100644 --- a/generate.py +++ b/generate.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # diff --git a/preprocess.py b/preprocess.py index 8edbaacd5..e46094b20 100644 --- a/preprocess.py +++ b/preprocess.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # diff --git a/score.py b/score.py index 1d3ba72fd..fc5633882 100644 --- a/score.py +++ b/score.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # diff --git a/setup.py b/setup.py index bb43387a7..7a2274c12 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # diff --git a/train.py b/train.py index 9966608a5..f9ac37206 100644 --- a/train.py +++ b/train.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. #