Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jan 19, 2024

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from Maxwell175 January 19, 2024 01:37
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery timed out performing refactorings.

Due to GitHub API limits, only the first 60 comments can be shown.

collect_ignore.append('docs/conf.py') # uses f-strings
collect_ignore.append('pavement.py')


collect_ignore.extend(('docs/conf.py', 'pavement.py'))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 45-48 refactored with the following changes:

This removes the following comments ( why? ):

# uses f-strings

Comment on lines -148 to +149
state = {}
g = globals()
for k, v in _state_vars.items():
state[k] = g['_sget_' + v](g[k])
return state
return {k: g[f'_sget_{v}'](g[k]) for k, v in _state_vars.items()}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function __getstate__ refactored with the following changes:

Comment on lines -158 to +155
g['_sset_' + _state_vars[k]](k, g[k], v)
g[f'_sset_{_state_vars[k]}'](k, g[k], v)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function __setstate__ refactored with the following changes:

Comment on lines -199 to +196
plat = 'macosx-%s-%s' % ('.'.join(_macos_vers()[:2]), m.group(3))
plat = f"macosx-{'.'.join(_macos_vers()[:2])}-{m.group(3)}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_supported_platform refactored with the following changes:

Comment on lines -362 to +359
if not self.requirers:
return 'the application'
return ', '.join(self.requirers)
return 'the application' if not self.requirers else ', '.join(self.requirers)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DistributionNotFound.requirers_str refactored with the following changes:

Comment on lines -588 to +573
def has_resource(resource_name):
def has_resource(self):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function IResourceProvider.has_resource refactored with the following changes:

Comment on lines -591 to +576
def resource_isdir(resource_name):
def resource_isdir(self):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function IResourceProvider.resource_isdir refactored with the following changes:

Comment on lines -594 to +579
def resource_listdir(resource_name):
def resource_listdir(self):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function IResourceProvider.resource_listdir refactored with the following changes:

Comment on lines -866 to +853
if dist is None:
requirers = required_by.get(req, None)
raise DistributionNotFound(req, requirers)
if dist is None:
requirers = required_by.get(req, None)
raise DistributionNotFound(req, requirers)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function WorkingSet._resolve_dist refactored with the following changes:

Comment on lines -911 to +896
plugin_projects = list(plugin_env)
# scan project names in alphabetic order
plugin_projects.sort()

plugin_projects = sorted(plugin_env)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function WorkingSet.find_plugins refactored with the following changes:

This removes the following comments ( why? ):

# scan project names in alphabetic order

Comment on lines -1275 to +1255
target_path = os.path.join(extract_path, archive_name + '-tmp', *names)
target_path = os.path.join(extract_path, f'{archive_name}-tmp', *names)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ResourceManager.get_cache_path refactored with the following changes:

Comment on lines -1416 to +1396
match = _PEP440_FALLBACK.search(version)
if match:
if match := _PEP440_FALLBACK.search(version):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _forgiving_version refactored with the following changes:

Comment on lines -1523 to +1502
exc.reason += ' in {} file at path: {}'.format(name, path)
exc.reason += f' in {name} file at path: {path}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NullProvider.get_metadata refactored with the following changes:

Comment on lines -1539 to +1518
if self.egg_info:
return self._listdir(self._fn(self.egg_info, name))
return []
return self._listdir(self._fn(self.egg_info, name)) if self.egg_info else []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NullProvider.metadata_listdir refactored with the following changes:

Comment on lines -1544 to +1521
script = 'scripts/' + script_name
script = f'scripts/{script_name}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function NullProvider.run_script refactored with the following changes:

Comment on lines -2653 to +2622
match = EGG_NAME(basename)
if match:
if match := EGG_NAME(basename):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution.from_location refactored with the following changes:

Comment on lines -2766 to +2734
msg = ("Missing 'Version:' header and/or {} file at path: {}").format(
self.PKG_INFO, path
)
msg = f"Missing 'Version:' header and/or {self.PKG_INFO} file at path: {path}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution.version refactored with the following changes:

Comment on lines -2796 to +2764
fails_marker = marker and (
if fails_marker := marker and (
invalid_marker(marker) or not evaluate_marker(marker)
)
if fails_marker:
):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution._filter_extras refactored with the following changes:

Comment on lines -2850 to +2815
version = _version_from_file(lines)

return version
return _version_from_file(lines)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution._get_version refactored with the following changes:

Comment on lines -2867 to +2833
filename = "%s-%s-py%s" % (
to_filename(self.project_name),
to_filename(self.version),
self.py_version or PY_MAJOR,
)
filename = f"{to_filename(self.project_name)}-{to_filename(self.version)}-py{self.py_version or PY_MAJOR}"

if self.platform:
filename += '-' + self.platform
filename += f'-{self.platform}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution.egg_name refactored with the following changes:

Comment on lines -2878 to +2837
if self.location:
return "%s (%s)" % (self, self.location)
else:
return str(self)
return f"{self} ({self.location})" if self.location else str(self)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution.__repr__ refactored with the following changes:

Comment on lines -2889 to +2845
return "%s %s" % (self.project_name, version)
return f"{self.project_name} {version}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution.__str__ refactored with the following changes:

Comment on lines -2899 to +2862
set(super().__dir__())
| set(attr for attr in self._provider.__dir__() if not attr.startswith('_'))
(
set(super().__dir__())
| {
attr
for attr in self._provider.__dir__()
if not attr.startswith('_')
}
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution.__dir__ refactored with the following changes:

Comment on lines -2912 to +2876
spec = "%s==%s" % (self.project_name, self.parsed_version)
spec = f"{self.project_name}=={self.parsed_version}"
else:
spec = "%s===%s" % (self.project_name, self.parsed_version)
spec = f"{self.project_name}==={self.parsed_version}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution.as_requirement refactored with the following changes:

Comment on lines -2933 to +2895
if group is not None:
return ep_map.get(group, {})
return ep_map
return ep_map.get(group, {}) if group is not None else ep_map
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Distribution.get_entry_map refactored with the following changes:

Comment on lines -1117 to +1109
return 'typing_extensions.' + self._name
return f'typing_extensions.{self._name}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _TypeAliasForm.__repr__ refactored with the following changes:

Comment on lines -1136 to +1128
return 'typing_extensions.' + self._name
return f'typing_extensions.{self._name}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _TypeAliasForm.__repr__ refactored with the following changes:

Comment on lines -1452 to +1444
return 'typing_extensions.' + self._name
return f'typing_extensions.{self._name}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _ConcatenateForm.__repr__ refactored with the following changes:

Comment on lines -1477 to +1469
return 'typing_extensions.' + self._name
return f'typing_extensions.{self._name}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _TypeGuardForm.__repr__ refactored with the following changes:

Comment on lines -1530 to +1522
return 'typing_extensions.' + self._name
return f'typing_extensions.{self._name}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _TypeGuardForm.__repr__ refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants