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

merge upstream (Sourcery refactored) #3

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

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 20, 2022

Pull Request #2 refactored by Sourcery.

Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to
    the original Pull Request

    Incorporate changes via command line
    git fetch https://github.com/synodriver/pycurl pull/2/head
    git merge --ff-only FETCH_HEAD
    git push

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from synodriver July 20, 2022 06:33
Comment on lines +46 to +52
elif s == arg:
# --option
# set value to True
p = True
del argv[i]
else:
if s == arg:
# --option
# set value to True
p = True
del argv[i]
else:
i = i + 1
i += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function scan_argv refactored with the following changes:

Comment on lines -72 to +71
i = i + 1
i += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function scan_argvs refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

Comment on lines -110 to +112
if not dir in self.library_dirs:
if dir not in self.library_dirs:
self.library_dirs.append(dir)
elif fatal:
fail("FATAL: bad directory %s in environment variable %s" % (dir, envvar))
fail(f"FATAL: bad directory {dir} in environment variable {envvar}")
Copy link
Author

Choose a reason for hiding this comment

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

Function ExtensionConfiguration.add_libdirs refactored with the following changes:

Comment on lines -149 to +152
if option != other_option:
if scan_argv(self.argv, other_option) is not None:
raise ConfigurationError('Cannot give both %s and %s' % (option, other_option))
if (
option != other_option
and scan_argv(self.argv, other_option) is not None
):
raise ConfigurationError(f'Cannot give both {option} and {other_option}')
Copy link
Author

Choose a reason for hiding this comment

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

Function ExtensionConfiguration.detect_ssl_option refactored with the following changes:

Comment on lines -160 to +173
if ssl_lib in ['openssl', 'wolfssl', 'gnutls', 'nss', 'mbedtls', 'sectransp']:
ssl_lib_detected = ssl_lib
getattr(self, 'using_%s' % ssl_lib)()
else:
if ssl_lib not in [
'openssl',
'wolfssl',
'gnutls',
'nss',
'mbedtls',
'sectransp',
]:
raise ConfigurationError('Invalid value "%s" for PYCURL_SSL_LIBRARY' % ssl_lib)

option = self.detect_ssl_option()
if option:
ssl_lib_detected = ssl_lib
getattr(self, f'using_{ssl_lib_detected}')()
if option := self.detect_ssl_option():
Copy link
Author

Choose a reason for hiding this comment

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

Function ExtensionConfiguration.detect_ssl_backend refactored with the following changes:

Comment on lines -761 to +759
f = open('doc/docstrings/%s' % entry)
f = open(f'doc/docstrings/{entry}')
Copy link
Author

Choose a reason for hiding this comment

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

Function convert_docstrings refactored with the following changes:

options.append((pycurl.PROXY, self._proxy_url.netloc))
else:
options.append((pycurl.PROXY, self._proxy_url.netloc))
options.append((pycurl.PROXY, self._proxy_url.netloc))
Copy link
Author

Choose a reason for hiding this comment

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

Function ProxyCURLHandlerPool.get_additional_curl_options refactored with the following changes:

if sys.version_info[0:2] < (major, minor):
if sys.version_info[:2] < (major, minor):
Copy link
Author

Choose a reason for hiding this comment

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

Function min_python refactored with the following changes:

Comment on lines -183 to +188
raise unittest.SkipTest('SSL backend is %s' % current_backend)
raise unittest.SkipTest(f'SSL backend is {current_backend}')

return fn(*args, **kwargs)

return decorated

Copy link
Author

Choose a reason for hiding this comment

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

Function only_ssl_backends refactored with the following changes:

Comment on lines -247 to +248
for i in range(num_attempts):
for _ in range(num_attempts):
Copy link
Author

Choose a reason for hiding this comment

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

Function wait_for_network_service refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jul 20, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 1.03%.

Quality metrics Before After Change
Complexity 12.55 🙂 11.39 🙂 -1.16 👍
Method Length 63.83 🙂 63.12 🙂 -0.71 👍
Working memory 7.14 🙂 7.04 🙂 -0.10 👍
Quality 64.47% 🙂 65.50% 🙂 1.03% 👍
Other metrics Before After Change
Lines 1265 1261 -4
Changed files Quality Before Quality After Quality Change
setup.py 54.92% 🙂 56.04% 🙂 1.12% 👍
requests_curl/pool.py 88.75% ⭐ 89.00% ⭐ 0.25% 👍
tests/util.py 88.88% ⭐ 89.06% ⭐ 0.18% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
setup.py ExtensionConfiguration.configure_unix 37 ⛔ 416 ⛔ 13 😞 18.86% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
setup.py ExtensionConfiguration.detect_ssl_backend 36 ⛔ 221 ⛔ 8 🙂 34.77% 😞 Refactor to reduce nesting. Try splitting into smaller methods
setup.py ExtensionConfiguration.configure_windows 16 🙂 321 ⛔ 10 😞 37.71% 😞 Try splitting into smaller methods. Extract out complex expressions
setup.py check_manifest 15 🙂 137 😞 12 😞 46.66% 😞 Try splitting into smaller methods. Extract out complex expressions
setup.py get_extension 4 ⭐ 173 😞 13 😞 51.47% 🙂 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@synodriver synodriver force-pushed the master branch 2 times, most recently from 69079b5 to fdb2b4a Compare August 2, 2022 13:49
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