Skip to content

Commit da280c7

Browse files
committed
Use append instead of += [stuff]
1 parent 4b48e14 commit da280c7

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

dfetch_hub/example_gui/gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def update_autocomplete(value: str) -> None:
139139
fuzz.ratio(value, project.src),
140140
)
141141
if ratio > 30 or url > 20 or repo_path > 20 or src > 20:
142-
sorted_list += [(ratio, project)]
142+
sorted_list.append((ratio, project))
143143
sorted_list.sort(key=lambda i: i[0], reverse=True)
144144
for ratio, project in sorted_list:
145145
add_project_to_page(project)

dfetch_hub/project/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, entries: Optional[List[Entry]] = None):
3434
self._entries = []
3535

3636
def add_entry(self, entry: Entry) -> None:
37-
self._entries += [entry]
37+
self._entries.append(entry)
3838

3939
@property
4040
def entries(self) -> List[Entry]:

dfetch_hub/project/project_finder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def filter_exclusions(self, paths: Union[List[str], Set[str]]) -> List[str]:
5151
if not path_allowed:
5252
break
5353
if path_allowed and path not in filtered_paths:
54-
filtered_paths += [path]
54+
filtered_paths.append(path)
5555
else:
5656
filtered_paths = list(paths)
5757
return filtered_paths
@@ -66,7 +66,7 @@ def add_exclusion(self, exclusion: Optional[str]) -> None:
6666
if exclusion:
6767
if not self._exclusions:
6868
self._exclusions = []
69-
self._exclusions += [exclusion]
69+
self._exclusions.append(exclusion)
7070
print(f"exclusions are {self.exclusions}")
7171

7272
def filter_projects(self) -> None:
@@ -163,7 +163,7 @@ def _projects_from_paths(
163163
project = RemoteProject(name, base_url, repo_path, src, vcs)
164164
project.versions.vcs = vcs
165165
project.add_versions(branches, tags)
166-
projects += [project]
166+
projects.append(project)
167167
return projects
168168

169169

dfetch_hub/project/project_parser.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@ def __init__(self) -> None:
2020
def add_project(self, new_project: RemoteProject) -> None:
2121
"""add a project"""
2222
if new_project not in self._projects:
23-
self._projects += [new_project]
23+
self._projects.append(new_project)
2424

2525
def get_projects(self) -> List[RemoteProject]:
2626
"""get all projects"""
2727
return self._projects
2828

2929
def get_projects_as_yaml(self) -> str:
3030
"""get yaml representation of projects"""
31-
yaml_str = ""
32-
yaml_obj: Dict[str, Any] = {"projects": []}
33-
for project in self._projects:
34-
yaml_obj["projects"] += [project.as_yaml()]
31+
yaml_obj: Dict[str, List] = {
32+
"projects": [project.as_yaml() for project in self._projects]
33+
}
3534
yaml_str = yaml.dump(yaml_obj)
3635
return yaml_str
3736

dfetch_hub/project/project_sources.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ def __init__(self, args: Union[Namespace, Dict[str, str]]):
1818

1919
def add_exclusion(self, exclusion_regex: str) -> None:
2020
"""add exclusion to project source"""
21-
if not self.exclusions:
22-
self.exclusions = [exclusion_regex]
23-
else:
24-
self.exclusions += [exclusion_regex]
21+
self.exclusions.append(exclusion_regex)
2522

2623
def as_yaml(self) -> Dict[str, Any]:
2724
"""get yaml representation"""
@@ -55,7 +52,7 @@ def __init__(self) -> None:
5552

5653
def add_remote(self, source: RemoteSource) -> None:
5754
"""add source"""
58-
self._sources += [source]
55+
self._sources.append(source)
5956

6057
def get_remotes(self) -> List[RemoteSource]:
6158
"""get list of sources"""

dfetch_hub/project/remote_datasource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ def add_tags(self, tags: Sequence[Tuple[str, str]]) -> None:
3636
"""add tags"""
3737
for hash_val, tag_name in tags:
3838
if tag_name not in [tag.name for tag in self.tags]:
39-
self.tags += [RemoteRef(tag_name, hash_val)]
39+
self.tags.append(RemoteRef(tag_name, hash_val))
4040

4141
def add_branches(self, branches: Sequence[Tuple[str, str]]) -> None:
4242
"""add branches"""
4343
for hash_val, branch_name in branches:
4444
if branch_name not in [branch.name for branch in self.branches]:
45-
self.branches += [RemoteRef(branch_name, hash_val)]
45+
self.branches.append(RemoteRef(branch_name, hash_val))
4646

4747
@property
4848
def default(self) -> str:

0 commit comments

Comments
 (0)