8000 Maint/fix manual by Remi-Gau · Pull Request #3 · Remi-Gau/boutiques · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Maint/fix manual #3

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

Closed
wants to merge 11 commits into from
Closed

Maint/fix manual #3

wants to merge 11 commits into from

Conversation

Remi-Gau
Copy link
Owner
@Remi-Gau Remi-Gau commented Jul 22, 2024

name: Feature or bug fix name
about: Propose modifications in the code
title: 'Feature implementation | Bug fix for issue #<000>'
labels: enhancement
assignees: ''


Related issues

Checklist

  • DO Unit tests pass.
  • DO If new feature, created unit test.
  • TRY If new API function, documented it (refer to
    PEP 257).

Purpose

Current behaviour

New behaviour

Does this introduce a major change?

  • Yes
  • No

Implementation Detail

Summary by Sourcery

This pull request includes bug fixes for exception handling and a typo correction. It also enhances the codebase by improving docstrings, replacing string formatting with f-strings, and removing unused variables.

  • Bug Fixes:
    • Fixed incorrect exception handling by removing unused exception variables.
    • Corrected typo in variable name from 'suggeseted_resources' to 'suggested_resources'.
  • Enhancements:
    • Improved docstrings for better clarity and consistency across multiple functions.
    • Replaced string formatting with f-strings for better readability and performance.
    • Removed unused variables and replaced them with underscores to indicate intentional non-use.

Copy link
sourcery-ai bot commented Jul 22, 2024

Reviewer's Guide by Sourcery

This pull request focuses on improving code readability and maintainability by removing unused variables, fixing typos, and enhancing docstrings across multiple files. The changes are primarily aimed at cleaning up the codebase without altering the core functionality.

File-Level Changes

Files Changes
boutiques/localExec.py
boutiques/importer.py
boutiques/descriptor2func.py
boutiques/bosh.py
boutiques/schema/examples/example1/exampleTool1_nonutf8.py
boutiques/zenodoHelper.py
boutiques/tests/test_logger.py
boutiques/validator.py
boutiques/boshParsers.py
boutiques/creator.py
boutiques/conftest.py
boutiques/tests/test_creator.py
boutiques/tests/test_deprecate.py
boutiques/prettyprint.py
boutiques/deprecate.py
boutiques/puller.py
boutiques/tests/test_search.py
docs/argparse_docs.py
boutiques/dataHandler.py
boutiques/test.py
Removed unused variables, fixed typos, and enhanced docstrings across multiple files for better readability and maintainability.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
@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.

Hey @Remi-Gau - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 10 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -40,11 +40,11 @@ def __init__(
):
try:
self.stdout = stdout.decode("utf=8", "backslashreplace")
except AttributeError as e:
except AttributeError:
Copy link

Choose a reason for hiding this comment

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

suggestion: Remove unused exception variable.

The exception variable 'e' was removed from the except block. This is a good practice if the variable is not used, but ensure that no logging or debugging information is lost.

Suggested change
except AttributeError:
except AttributeError:
logging.debug("AttributeError encountered, setting self.stdout to stdout")

@@ -246,7 +248,7 @@ def execute(self, mount_strings):
conType, conImage = con.get("type"), (
con.get("image") if not self.noContainer else None
)
conIndex = con.get("index")
_ = con.get("index")
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider removing unused variable assignment.

The variable 'conIndex' was replaced with '_', indicating it is unused. If this value is truly unnecessary, consider removing the assignment entirely to clean up the code.

Suggested change
_ = con.get("index")
conOpts = con.get("container-opts")
conIsPresent = conImage is not None

@@ -1070,7 +1072,7 @@ def checkMutualRequirements(targ):
for r in result:
self.in_dict[r["id"]] = makeParam(r)
# Check for mutex between in_dict and last in param
for group, mbs in [
for _, mbs in [
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider removing unused loop variable.

The loop variable 'group' was replaced with '_', indicating it is unused. If the variable is truly unnecessary, consider refactoring the loop to avoid creating unused variables.

Suggested change
for _, mbs in [
for mbs in (x["members"] for x in self.groups):

@@ -430,7 +430,7 @@ def parse_req(req, req_type, bout_desc):
if req.get("ramMin"):
suggested_resources["ram"] = req["ramMin"]
if req.get("coresMin"):
suggeseted_resources["cpu-cores"] = req["coresMin"]
suggested_resources["cpu-cores"] = req["coresMin"]
Copy link

Choose a reason for hiding this comment

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

issue (typo): Fix typo in variable name.

The typo 'suggeseted_resources' was corrected to 'suggested_resources'. Ensure that this change is reflected throughout the codebase.

@@ -83,7 +83,7 @@ def execute(*params):
try:
# Try to parse input with argparse
results, _ = parser.parse_known_args(params)
except SystemExit as e:
except SystemExit:
Copy link

Choose a reason for hiding this comment

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

suggestion: Remove unused exception variable.

The exception variable 'e' was removed from the except block. This is a good practice if the variable is not used, but ensure that no logging or debugging information is lost.

Suggested change
except SystemExit:
except SystemExit as e:
print_info(execute.__doc__)
raise_error(ExecutorError, f"Incorrect usage of 'bosh exec': {e}")

@@ -188,7 +181,7 @@ def getSubstringType(s):
for mid in inIds
if inById(mid)["value-key"] == key
]
for idx, grp in enumerate(descriptor.get("groups")):
for _, grp in enumerate(descriptor.get("groups")):
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider removing unused loop variable.

The loop variable 'idx' was replaced with '_', indicating it is unused. If the variable is truly unnecessary, consider refactoring the loop to avoid creating unused variables.

Suggested change
for _, grp in enumerate(descriptor.get("groups")):
for grp in descriptor.get("groups", []):

@@ -205,7 +203,7 @@ def parseAction(self, action, **kwargs):
actstring = str(type(action))
actstring = actstring.split("'")[1].split(".")[-1]
print_info(f"{actstring}: Adding")
actdict = vars(action)
_ = vars(action)
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider removing unused variable assignment.

The variable 'actdict' was replaced with '_', indicating it is unused. If this value is truly unnecessary, consider removing the assignment entirely to clean up the code.

Suggested change
_ = vars(action)
# Removed unused variable assignment
if action.dest == "==SUPPRESS==":
adest = f"subparser_{self.sp_count}"



def compute_md5(filename):
with open(filename, "rb") as fhandle:
with open(filename, "rb"):
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Fix file handling issue.

The file handle 'fhandle' was removed, but the file is still being opened. Ensure that the file is properly handled and closed to avoid resource leaks.

Comment on lines 174 to 176
for r in results:
for k, v in r.items():
for _, v in r.items():
self.assertLessEqual(len(str(v)), 43)
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Avoid loops in tests. (no-loop-in-tests)

ExplanationAvoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:

  • loops
  • conditionals

Some ways to fix this:

  • Use parametrized tests to get rid of the loop.
  • Move the complex logic into helpers.
  • Move the complex part into pytest fixtures.

Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / Don't Put Logic in Tests

Comment on lines +175 to 176
for _, v in r.items():
self.assertLessEqual(len(str(v)), 43)
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Avoid loops in tests. (no-loop-in-tests)

ExplanationAvoid complex code, like loops, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:

  • loops
  • conditionals

Some ways to fix this:

  • Use parametrized tests to get rid of the loop.
  • Move the complex logic into helpers.
  • Move the complex part into pytest fixtures.

Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / Don't Put Logic in Tests

@coveralls
Copy link

Pull Request Test Coverage Report for Build 10041893254

Details

  • 47 of 54 (87.04%) changed or added relevant lines in 19 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.1%) to 74.473%

Changes Missing Coverage Covered Lines Changed/Added Lines %
boutiques/localExec.py 5 6 83.33%
boutiques/test.py 0 1 0.0%
boutiques/tests/test_deprecate.py 2 3 66.67%
boutiques/conftest.py 0 2 0.0%
boutiques/importer.py 3 5 60.0%
Files with Coverage Reduction New Missed Lines %
boutiques/descriptor2func.py 1 16.67%
Totals Coverage Status
Change from base Build 10041815223: -0.1%
Covered Lines: 4455
Relevant Lines: 5982

💛 - Coveralls

@Remi-Gau Remi-Gau closed this Jan 18, 2025
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.

2 participants
0