Skip to content

Commit

Permalink
Replace type(1) == int with isinstance(1, int) (ultralytics#11951)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit suggestions

updates:
- [github.com/asottile/pyupgrade: v3.8.0 → v3.10.1](asottile/pyupgrade@v3.8.0...v3.10.1)
- [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](PyCQA/flake8@6.0.0...6.1.0)

* Update __init__.py

Signed-off-by: Glenn Jocher <[email protected]>

* Update __init__.py

Signed-off-by: Glenn Jocher <[email protected]>

---------

Signed-off-by: Glenn Jocher <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and glenn-jocher authored Aug 7, 2023
1 parent 0897415 commit cffd248
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/asottile/pyupgrade
rev: v3.8.0
rev: v3.10.1
hooks:
- id: pyupgrade
name: Upgrade code
Expand Down Expand Up @@ -50,7 +50,7 @@ repos:
# exclude: "README.md|README.zh-CN.md|CONTRIBUTING.md"

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
name: PEP8
Expand Down
7 changes: 3 additions & 4 deletions utils/loggers/comet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,14 @@ def download_dataset_artifact(self, artifact_path):
data_dict['path'] = artifact_save_dir

metadata_names = metadata.get('names')
if type(metadata_names) == dict:
if isinstance(metadata_names, dict):
data_dict['names'] = {int(k): v for k, v in metadata.get('names').items()}
elif type(metadata_names) == list:
elif isinstance(metadata_names, list):
data_dict['names'] = {int(k): v for k, v in zip(range(len(metadata_names)), metadata_names)}
else:
raise "Invalid 'names' field in dataset yaml file. Please use a list or dictionary"

data_dict = self.update_data_paths(data_dict)
return data_dict
return self.update_data_paths(data_dict)

def update_data_paths(self, data_dict):
path = data_dict.get('path', '')
Expand Down

0 comments on commit cffd248

Please sign in to comment.