Skip to content

Commit 990dd08

Browse files
author
syumeikoukyo
committed
add #type ignore
1 parent 0d7e041 commit 990dd08

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

run-clang-format.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
try:
5050
from subprocess import DEVNULL # py3k
5151
except ImportError:
52-
DEVNULL = open(os.devnull, "wb")
52+
DEVNULL = open(os.devnull, "wb") # type: ignore
5353

5454

5555
DEFAULT_EXTENSIONS = "c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx"
@@ -101,7 +101,8 @@ def list_files(files, recursive=False, extensions=None, exclude=None):
101101
for x in dnames
102102
if not fnmatch.fnmatch(os.path.join(dirpath, x), pattern)
103103
]
104-
fpaths = [x for x in fpaths if not fnmatch.fnmatch(x, pattern)]
104+
fpaths = [
105+
x for x in fpaths if not fnmatch.fnmatch(x, pattern)]
105106
for f in fpaths:
106107
ext = os.path.splitext(f)[1][1:]
107108
if ext in extensions:
@@ -143,7 +144,8 @@ def run_clang_format_diff_wrapper(args, file):
143144
except DiffError:
144145
raise
145146
except Exception as e:
146-
raise UnexpectedError("{}: {}: {}".format(file, e.__class__.__name__, e), e)
147+
raise UnexpectedError("{}: {}: {}".format(
148+
file, e.__class__.__name__, e), e)
147149

148150

149151
def run_clang_format_diff(args, file):
@@ -374,7 +376,8 @@ def main():
374376
pool = None
375377
else:
376378
pool = multiprocessing.Pool(njobs)
377-
it = pool.imap_unordered(partial(run_clang_format_diff_wrapper, args), files)
379+
it = pool.imap_unordered(
380+
partial(run_clang_format_diff_wrapper, args), files)
378381
while True:
379382
try:
380383
outs, errs = next(it)

setup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
"""The setup script."""
55

6-
from setuptools import setup, find_packages
7-
from setuptools.dist import Distribution
8-
from setuptools.command.install import install
6+
from setuptools import setup, find_packages # type: ignore
7+
from setuptools.dist import Distribution # type: ignore
8+
from setuptools.command.install import install # type: ignore
99

1010
import os
1111

@@ -22,9 +22,9 @@ def read(fname):
2222
return fp.read()
2323

2424

25-
requirements = []
25+
requirements = [] # type: ignore
2626

27-
setup_requirements = []
27+
setup_requirements = [] # type: ignore
2828

2929

3030
setup(
@@ -50,7 +50,7 @@ def read(fname):
5050
keywords="pydp",
5151
name="python-dp",
5252
package_dir={"": "src"},
53-
package_data={"pydp": ["_pydp.so", "_pydp.pyd"],},
53+
package_data={"pydp": ["_pydp.so", "_pydp.pyd"], },
5454
packages=find_packages(where="src", exclude=["tests"]),
5555
setup_requires=setup_requirements,
5656
test_suite="tests",

tests/algorithms/test_bounded_mean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import os
22
import pytest
33
from pydp.algorithms.laplacian import BoundedMean
4-
from pydp._pydp import Summary
4+
from pydp._pydp import Summary # type: ignore
55

66

7-
expect_near = lambda expected, actual, tol: (
7+
def expect_near(expected, actual, tol): return (
88
expected + tol >= actual and expected - tol <= actual
99
)
1010

tests/algorithms/test_distributions.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import pytest
2-
from pydp.distributions import (
3-
LaplaceDistribution,
4-
GaussianDistribution,
5-
GeometricDistribution,
6-
)
2+
from pydp.distributions import LaplaceDistribution # type: ignore
3+
from pydp.distributions import GaussianDistribution # type: ignore
4+
from pydp.distributions import GeometricDistribution # type: ignore
75
import pydp as dp
86
import math
97
from typing import List
@@ -24,7 +22,8 @@ def skew(samples: List[float], mu: float, sigma: float):
2422
Until then this should suffice. #FIXME: when possible we can fix this.
2523
"""
2624
skew = list(
27-
accumulate(samples, lambda lhs, rhs: lhs + (rhs - mu) * (rhs - mu) * (rhs - mu))
25+
accumulate(samples, lambda lhs, rhs: lhs +
26+
(rhs - mu) * (rhs - mu) * (rhs - mu))
2827
)[-1]
2928
return skew / (len(samples) * sigma * sigma * sigma)
3029

@@ -36,7 +35,8 @@ def kurtosis(samples: List[float], mu: float, var: float):
3635
Until then this should suffice. #FIXME: when possible we can fix this.
3736
"""
3837
kurt = list(
39-
accumulate(samples, lambda lhs, rhs: lhs + ((rhs - mu) * (rhs - mu)) ** 2)
38+
accumulate(samples, lambda lhs, rhs: lhs +
39+
((rhs - mu) * (rhs - mu)) ** 2)
4040
)[-1]
4141
n = len(samples)
4242
kurt = (n + 1) * kurt / (n * var * var)
@@ -48,7 +48,7 @@ def kurtosis(samples: List[float], mu: float, var: float):
4848
# From what I understand @openmined/dp-research are going to look at validating correctness
4949
# Until then we can use this to assert on floating point numbers.
5050
# FIXME: When possible we should add 'correctness' tests.
51-
expect_near = lambda expected, actual, tol: (
51+
def expect_near(expected, actual, tol): return (
5252
expected + tol >= actual and expected - tol <= actual
5353
)
5454

@@ -62,7 +62,8 @@ def test_diversity_getter(self):
6262
def test_check_statistics_for_geo_unit_values(self):
6363

6464
ld = LaplaceDistribution(epsilon=1.0, sensitivity=1.0)
65-
samples = [ld.sample(scale=1.0) for _ in range(k_num_geometric_samples)]
65+
samples = [ld.sample(scale=1.0)
66+
for _ in range(k_num_geometric_samples)]
6667
mean = dp.util.mean(samples)
6768
var = dp.util.variance(samples)
6869

tests/algorithms/test_rand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from pydp.util import Geometric, UniformDouble
2+
from pydp.util import Geometric, UniformDouble # type: ignore
33

44

55
def test_rand_UniformDouble():

0 commit comments

Comments
 (0)