-
Notifications
You must be signed in to change notification settings - Fork 7
Create hello1.py #97
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
base: master
Are you sure you want to change the base?
Create hello1.py #97
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| import random | ||
| import pdb | ||
| import sys as sys | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| import os | ||
| import subprocess | ||
| import abc | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # from django.db.models.expressions import RawSQL | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| AWS_SECRET_KEY = "d6s$f9g!j8mg7hw?n&2" | ||
|
|
||
|
|
||
| class BaseNumberGenerator: | ||
| """Declare a method -- `get_number`.""" | ||
|
|
||
| def __init__(self): | ||
| self.limits = (1, 10) | ||
|
|
||
| def get_number(self, min_max): | ||
| raise NotImplemented | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| def smethod(): | ||
| """static method-to-be""" | ||
|
|
||
| smethod = staticmethod(smethod) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| def cmethod(cls, something): | ||
| """class method-to-be""" | ||
|
|
||
| cmethod = classmethod(cmethod) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
|
|
||
| class RandomNumberGenerator: | ||
| """Generate random numbers.""" | ||
|
|
||
| def limits(self): | ||
| return self.limits | ||
|
|
||
| def get_number(self, min_max=[1, 10]): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| """Get a random number between min and max.""" | ||
| assert all([isinstance(i, int) for i in min_max]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return random.randint(*min_max) | ||
|
|
||
|
|
||
| def main(options: dict = {}) -> str: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| pdb.set_trace() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if "run" in options: | ||
| value = options["run"] | ||
| else: | ||
| value = "default_value" | ||
|
|
||
| if type(value) != str: | ||
| raise Exception() | ||
| else: | ||
| value = iter(value) | ||
|
|
||
| sorted(value, key=lambda k: len(k)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| f = open("/tmp/.deepsource.toml", "r") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| f.write("config file.") | ||
|
Comment on lines
+59
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| f.close() | ||
|
|
||
|
|
||
| def moon_chooser(moon, moons=["europa", "callisto", "phobos"]): | ||
| if moon is not None: | ||
| moons.append(moon) | ||
|
Comment on lines
+64
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| return random.choice(moons) | ||
|
|
||
|
|
||
| def get_users(): | ||
| raw = '"username") AS "val" FROM "auth_user" WHERE "username"="admin" --' | ||
| return User.objects.annotate(val=RawSQL(raw, [])) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
|
|
||
| def tar_something(): | ||
| os.tempnam("dir1") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| subprocess.Popen("/bin/chown *", shell=True) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| o.system("/bin/tar xvzf *") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
|
|
||
| def bad_isinstance(initial_condition, object, other_obj, foo, bar, baz): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| initial_condition | ||
| and ( | ||
| isinstance(object, int) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| or isinstance(object, float) | ||
| or isinstance(object, str) | ||
| ) | ||
| and isinstance(other_obj, float) | ||
| and isinstance(foo, str) | ||
| or (isinstance(bar, float) or isinstance(bar, str)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| and (isinstance(baz, float) or isinstance(baz, int)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ): | ||
| pass | ||
|
|
||
|
|
||
| def check(x): | ||
| if x == 1 or x == 2 or x == 3: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| print("Yes") | ||
| elif x != 2 or x != 3: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| print("also true") | ||
|
|
||
| elif x in (2, 3) or x in (5, 4): | ||
| print("Here") | ||
|
|
||
| elif x == 10 or x == 20 or x == 30 and x == 40: | ||
| print("Sweet!") | ||
|
|
||
| elif x == 10 or x == 20 or x == 30: | ||
| print("Why even?") | ||
|
|
||
| def chained_comparison(): | ||
| a = 1 | ||
| b = 2 | ||
| c = 3 | ||
| return a < b and b < c | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| if __name__ == "__main__": | ||
| args = ["--disable", "all"] | ||
| f = open("/tmp/.deepsource.toml", "r") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| f.write("config file.") | ||
|
Comment on lines
+121
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| f.close() | ||
| assert args is not None | ||
| for i in range(len(args)): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| has_truthy = True if args[i] else False | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| assert has_truthy is not None | ||
| if has_truthy: | ||
| break | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import statement
import pdbbrings in the Python debugger, which may lead to accidental invocation of interactive debugging sessions in production or shared code, disrupting execution and revealing internal states.Remove the
import pdbstatement from committed code to ensure debuggers are only used temporarily during development.