Skip to content

Commit 6b051e3

Browse files
committed
fix(lint): linting fixes
1 parent 1228f09 commit 6b051e3

File tree

8 files changed

+88
-52
lines changed

8 files changed

+88
-52
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
- uses: actions/setup-node@v1
4040
with:
4141
node-version: '12.x'
42+
- run: npm i -g yarn
43+
- run: yarn set version berry
4244
- name: Cache Conda
4345
uses: actions/cache@v1
4446
with:
@@ -49,7 +51,7 @@ jobs:
4951
- uses: conda-incubator/setup-miniconda@v2
5052
with:
5153
python-version: 3.8
52-
mamba-version: "*"
54+
mamba-version: '*'
5355
channels: conda-forge,defaults
5456
channel-priority: true
5557
activate-environment: upsetjs_jupyter_widget
@@ -58,18 +60,18 @@ jobs:
5860
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
5961
- name: pytest
6062
shell: bash -l {0}
61-
run: npm run test:p:ci
63+
run: yarn test:p:ci
6264
- name: Lint
6365
shell: bash -l {0}
64-
run: npm run lint:p
66+
run: yarn lint:p
6567

6668
- name: Build Notebooks
6769
shell: bash -l {0}
68-
run: npm run nbconvert
70+
run: yarn nbconvert
6971

7072
- name: Create Docu
7173
shell: bash -l {0}
72-
run: npm run docs:p
74+
run: yarn docs:p
7375

7476
- run: |
7577
mkdir -p public/integrations/jupyter

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ disable=bad-continuation,
66
line-too-long,
77
duplicate-code,
88
too-many-arguments,
9-
too-many-ancestors
9+
too-many-ancestors,
10+
unsubscriptable-object

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ dependencies:
1010
- bumpversion
1111
- pytest
1212
- jupyter
13-
- jupyterlab
13+
- jupyterlab
1414
- pytest-cov

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"lint": "yarn run eslint && yarn run prettier:check",
4646
"fix": "yarn run eslint:fix && yarn run prettier:write",
4747
"prettier": "prettier \"*.{md,json,yml}\" .eslintrc.js webpack* .prettierrc.js \"{src,types,scripts,.github}/**\" \"{r_package,binder}/*.yml\"",
48-
"prettier:write": "yarn run prettier -- --write",
49-
"prettier:check": "yarn run prettier -- --check",
50-
"black": "black --target-version=py37 upsetjs_jupyter_widget setup.py setupbase.py",
48+
"prettier:write": "yarn run prettier --write",
49+
"prettier:check": "yarn run prettier --check",
50+
"black": "black --target-version=py38 upsetjs_jupyter_widget setup.py setupbase.py",
5151
"eslint": "eslint src --ext .ts,.tsx",
52-
"eslint:fix": "yarn run eslint -- --fix",
53-
"lint:p": "mypy -p upsetjs_jupyter_widget && yarn run black -- --check && pylint upsetjs_jupyter_widget",
52+
"eslint:fix": "yarn run eslint --fix",
53+
"lint:p": "mypy -p upsetjs_jupyter_widget && yarn run black --check && pylint upsetjs_jupyter_widget",
5454
"fix:p": "yarn run black",
5555
"test:p": "pytest",
5656
"test:p:ci": "pytest --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html",

setup.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
"jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec
5555
)
5656
cmdclass["jsdeps"] = combine_commands(
57-
install_npm(HERE, build_cmd="build:all"), ensure_targets(jstargets),
57+
install_npm(HERE, build_cmd="build:all"),
58+
ensure_targets(jstargets),
5859
)
5960

6061

@@ -93,9 +94,15 @@
9394
"Typing :: Typed",
9495
],
9596
include_package_data=True,
96-
install_requires=["ipywidgets>=7.5.0",],
97+
install_requires=[
98+
"ipywidgets>=7.5.0",
99+
],
97100
extras_require={
98-
"test": ["pytest>=3.6", "pytest-cov", "nbval",],
101+
"test": [
102+
"pytest>=3.6",
103+
"pytest-cov",
104+
"nbval",
105+
],
99106
"examples": [
100107
# Any requirements for the examples to run
101108
],

setupbase.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ def list2cmdline(cmd_list):
6161
SEPARATORS = os.sep if os.altsep is None else os.sep + os.altsep
6262

6363
npm_path = ":".join(
64-
[pjoin(HERE, "node_modules", ".bin"), os.environ.get("PATH", os.defpath),]
64+
[
65+
pjoin(HERE, "node_modules", ".bin"),
66+
os.environ.get("PATH", os.defpath),
67+
]
6568
)
6669

6770
if "--skip-npm" in sys.argv:
@@ -89,8 +92,7 @@ def get_version(file, name="__version__"):
8992

9093

9194
def ensure_python(specs):
92-
"""Given a list of range specifiers for python, ensure compatibility.
93-
"""
95+
"""Given a list of range specifiers for python, ensure compatibility."""
9496
if not isinstance(specs, (list, tuple)):
9597
specs = [specs]
9698
v = sys.version_info
@@ -228,7 +230,7 @@ def run(cmd, **kwargs):
228230

229231
def is_stale(target, source):
230232
"""Test whether the target file/directory is stale based on the source
231-
file/directory.
233+
file/directory.
232234
"""
233235
if not os.path.exists(target):
234236
return True
@@ -500,8 +502,7 @@ def run(self):
500502

501503

502504
def _get_file_handler(package_data_spec, data_files_spec):
503-
"""Get a package_data and data_files handler command.
504-
"""
505+
"""Get a package_data and data_files handler command."""
505506

506507
class FileHandler(BaseCommand):
507508
def run(self):

upsetjs_jupyter_widget/tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import pytest
1616

17-
from ipykernel.comm import Comm
18-
from ipywidgets import Widget
17+
from ipykernel.comm import Comm # type: ignore
18+
from ipywidgets import Widget # type: ignore
1919

2020

2121
class MockComm(Comm):
@@ -34,7 +34,7 @@ def __init__(self, *args, **kwargs):
3434
self.log_open = []
3535
self.log_send = []
3636
self.log_close = []
37-
super(MockComm, self).__init__(*args, **kwargs)
37+
super().__init__(*args, **kwargs)
3838

3939
def open(self, *args, **kwargs):
4040
"""

upsetjs_jupyter_widget/widget.py

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
import typing as t
1212

13-
from ipywidgets import DOMWidget, Layout, ValueWidget, register
14-
from ipywidgets.widgets.trait_types import Color
15-
from traitlets import (
13+
from ipywidgets import DOMWidget, Layout, ValueWidget, register # type: ignore
14+
from ipywidgets.widgets.trait_types import Color # type: ignore
15+
from traitlets import ( # type: ignore
1616
Bool,
1717
Dict,
1818
Enum,
@@ -53,7 +53,9 @@
5353

5454

5555
def _sort_sets(
56-
sets: t.Sequence[UpSetSet[T]], order_by: str, limit: t.Optional[int] = None,
56+
sets: t.Sequence[UpSetSet[T]],
57+
order_by: str,
58+
limit: t.Optional[int] = None,
5759
) -> t.List[UpSetSet[T]]:
5860
key = None
5961
if order_by == "cardinality":
@@ -145,24 +147,35 @@ def _create_combination(
145147
) -> UpSetSetCombination:
146148
if combination_type == UpSetSetType.DISTINCT_INTERSECTION:
147149
return UpSetSetDistinctIntersection[T](
148-
cs_name, sets=sets, color=color_lookup.get(cs_name), cardinality=count,
150+
cs_name,
151+
sets=sets,
152+
color=color_lookup.get(cs_name),
153+
cardinality=count,
149154
)
150155
if combination_type == UpSetSetType.INTERSECTION:
151156
return UpSetSetIntersection[T](
152-
cs_name, sets=sets, color=color_lookup.get(cs_name), cardinality=count,
157+
cs_name,
158+
sets=sets,
159+
color=color_lookup.get(cs_name),
160+
cardinality=count,
153161
)
154162
if combination_type == UpSetSetType.UNION:
155163
return UpSetSetUnion[T](
156-
cs_name, sets=sets, color=color_lookup.get(cs_name), cardinality=count,
164+
cs_name,
165+
sets=sets,
166+
color=color_lookup.get(cs_name),
167+
cardinality=count,
157168
)
158169
return UpSetSetComposite[T](
159-
cs_name, sets=sets, color=color_lookup.get(cs_name), cardinality=count,
170+
cs_name,
171+
sets=sets,
172+
color=color_lookup.get(cs_name),
173+
cardinality=count,
160174
)
161175

162176

163177
class UpSetJSBaseWidget(ValueWidget, DOMWidget, t.Generic[T]):
164-
"""UpSet.js Base Widget
165-
"""
178+
"""UpSet.js Base Widget"""
166179

167180
_model_name = Unicode("UpSetModel").tag(sync=True)
168181
_model_module = Unicode(MODULE_NAME).tag(sync=True)
@@ -185,12 +198,14 @@ class UpSetJSBaseWidget(ValueWidget, DOMWidget, t.Generic[T]):
185198
elems: t.List[T] = List(default_value=[]).tag(sync=True)
186199
elem_to_index: t.Dict[T, int] = {}
187200

188-
sets: t.List[UpSetSet[T]] = List(Instance(UpSetSet), default_value=[],).tag(
189-
sync=True, to_json=_to_set_list
190-
)
201+
sets: t.List[UpSetSet[T]] = List(
202+
Instance(UpSetSet),
203+
default_value=[],
204+
).tag(sync=True, to_json=_to_set_list)
191205

192206
combinations: t.List[UpSetSetCombination[T]] = List(
193-
Instance(UpSetSetCombination), default_value=[],
207+
Instance(UpSetSetCombination),
208+
default_value=[],
194209
).tag(sync=True, to_json=_to_combination_list)
195210

196211
value: t.Union[None, t.Mapping, t.List[int]] = Union(
@@ -424,7 +439,7 @@ def _from_dict(
424439
elems: t.Set[T] = set()
425440
for set_elems in sets.values():
426441
elems.update(set_elems)
427-
self.elems = sorted(elems)
442+
self.elems = sorted(elems) # type: ignore
428443
self.elem_to_index = {e: i for i, e in enumerate(self.elems)}
429444
self._expression_data = False
430445
color_lookup = colors or {}
@@ -539,8 +554,7 @@ def to_set(name: str, series):
539554

540555
@register
541556
class UpSetJSWidget(UpSetJSBaseWidget, t.Generic[T]):
542-
"""UpSet.js Widget
543-
"""
557+
"""UpSet.js Widget"""
544558

545559
_render_mode = Unicode("upset").tag(sync=True)
546560

@@ -706,7 +720,12 @@ def generate_distinct_intersections(
706720
customize the generation of the sets
707721
"""
708722
set_intersections = generate_distinct_intersections(
709-
self.sets, min_degree, max_degree, empty, self.elems, colors=colors,
723+
self.sets,
724+
min_degree,
725+
max_degree,
726+
empty,
727+
self.elems,
728+
colors=colors,
710729
)
711730

712731
self.combinations = _sort_combinations(
@@ -727,7 +746,12 @@ def generate_unions(
727746
customize the generation of the sets
728747
"""
729748
set_unions = generate_unions(
730-
self.sets, min_degree, max_degree, empty, self.elems, colors=colors,
749+
self.sets,
750+
min_degree,
751+
max_degree,
752+
empty,
753+
self.elems,
754+
colors=colors,
731755
)
732756

733757
self.combinations = _sort_combinations(set_unions, self.sets, order_by, limit)
@@ -766,7 +790,7 @@ def append_categorical_attribute(
766790
"""
767791
adds another categorical UpSetAttribute to be visualized
768792
"""
769-
cats = categories if categories is not None else sorted(set(values))
793+
cats = categories if categories is not None else list(sorted(set(values)))
770794
self.attrs = self.attrs + [
771795
UpSetAttribute[T]("categorical", name, values, categories=cats)
772796
]
@@ -775,8 +799,7 @@ def append_categorical_attribute(
775799

776800
@register
777801
class UpSetJSVennDiagramWidget(UpSetJSBaseWidget, t.Generic[T]):
778-
"""UpSet.js Venn Diagram Widget
779-
"""
802+
"""UpSet.js Venn Diagram Widget"""
780803

781804
_render_mode = Unicode("venn").tag(sync=True)
782805

@@ -825,7 +848,9 @@ def from_dataframe(
825848
return self._generate_distinct_intersections(base_sets, colors=colors)
826849

827850
def _generate_distinct_intersections(
828-
self, base_sets: t.List[UpSetSet[T]], colors: t.Mapping[str, str] = None,
851+
self,
852+
base_sets: t.List[UpSetSet[T]],
853+
colors: t.Mapping[str, str] = None,
829854
) -> "UpSetJSVennDiagramWidget":
830855
set_intersections = generate_distinct_intersections(
831856
base_sets, 1, None, True, self.elems, colors=colors
@@ -839,8 +864,7 @@ def _generate_distinct_intersections(
839864

840865
@register
841866
class UpSetJSEulerDiagramWidget(UpSetJSVennDiagramWidget, t.Generic[T]):
842-
"""UpSet.js Euler Diagram Widget
843-
"""
867+
"""UpSet.js Euler Diagram Widget"""
844868

845869
def __init__(self, **kwargs):
846870
super().__init__(**kwargs)
@@ -860,8 +884,7 @@ def copy(self) -> "UpSetJSEulerDiagramWidget":
860884

861885
@register
862886
class UpSetJSKarnaughMapWidget(UpSetJSBaseWidget, t.Generic[T]):
863-
"""UpSet.js Karnaugh Map Widget
864-
"""
887+
"""UpSet.js Karnaugh Map Widget"""
865888

866889
_render_mode = Unicode("kmap").tag(sync=True)
867890

@@ -915,7 +938,9 @@ def from_dataframe(
915938
return self._generate_distinct_intersections(base_sets, colors=colors)
916939

917940
def _generate_distinct_intersections(
918-
self, base_sets: t.List[UpSetSet[T]], colors: t.Mapping[str, str] = None,
941+
self,
942+
base_sets: t.List[UpSetSet[T]],
943+
colors: t.Mapping[str, str] = None,
919944
) -> "UpSetJSKarnaughMapWidget":
920945
set_intersections = generate_distinct_intersections(
921946
base_sets, 1, None, True, self.elems, colors=colors

0 commit comments

Comments
 (0)