Skip to content

Conversation

ankit-amazon
Copy link
Contributor

Description of changes:

  • Rules Added: python/notebook-variable-redefinition@v1.0
  • Added compliant and non compliant examples

}
],
"source": [
"# Compliant: even though there are 2 different types assigned to variable `z`, it is only used within the same cells.\n",

Choose a reason for hiding this comment

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

Even though there are 2 different types assigned to variable z in two different cells, it is only used within one of the two cells.

Copy link
Contributor

@san2488 san2488 left a comment

Choose a reason for hiding this comment

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

DetectorLibrary only supports .py files.

],
"source": [
"# Noncompliant: variable `z` is assigned to 2 different types of values in above cells 3 and 4. \n",
"# Then in cell 5, the value of `z` is used in a `print()` call.\n",

Choose a reason for hiding this comment

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

Then in cell 5, the value of z is used in a print() call, which can have different result depending on the execution order of cells. \n"

# SPDX-License-Identifier: Apache-2.0

# {fact rule=notebook-variable-redefinition@v1.0 defects=1}
# —— Code Cell 1, Execution Count 1 —— #

Choose a reason for hiding this comment

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

In this example, remove all Execution Count, as this information is not needed
Write this.
# —— Code Cell 1—— #

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.

3 participants