Skip to content

Commit

Permalink
Add ugly_module
Browse files Browse the repository at this point in the history
  • Loading branch information
shnela committed Jun 20, 2022
1 parent d5e2d01 commit e115585
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
23 changes: 20 additions & 3 deletions 500 - Python style/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,34 @@ import this
>
> In particular: do not break backwards compatibility just to comply with this PEP!
### [🎵 The PEP 8 Song 🎵]

### What is Lint?
> In computer programming lint or lint-like tools performing static analysis of
> source code checking for symantec discrepancies.
>
> “Linting” means running a basic quality tool against your code.
> The tool will check your code syntax and provide instructions on how to clean it.
Python Lint tools:
From [What is Flake8 and why we should use it?]

#### Python Lint tools:
* [flake8]
* [pylint]
* [black]

```shell
# in env
pip install flake8 pylint
flake8 ugly_module
# flake8 is complaining
pylint ugly_module
# pylint is complaining even more
black ugly_module
# black makes some changes
```
* [ugly_exercise.py](ugly_module/ugly_exercise.py)

### [🎵 The PEP 8 Song 🎵]

## Exercises:
* [enum_exercise.py](enum_exercise.py)
Expand All @@ -65,7 +81,8 @@ Python Lint tools:
[PEP 8 - Style Guide for Python Code]: https://www.python.org/dev/peps/pep-0008/
[PEP 20 - The Zen of Python]: https://www.python.org/dev/peps/pep-0020/
[PEP 8 — the Style Guide for Python Code (for humans)]: https://pep8.org/
[🎵 The PEP 8 Song 🎵]: https://www.youtube.com/watch?v=hgI0p1zf31k
[What is Flake8 and why we should use it?]: https://medium.com/python-pandemonium/what-is-flake8-and-why-we-should-use-it-b89bd78073f2
[flake8]:https://flake8.pycqa.org/en/latest/
[pylint]: https://pylint.org/
[🎵 The PEP 8 Song 🎵]: https://www.youtube.com/watch?v=hgI0p1zf31k
[black]: https://pypi.org/project/black/
Empty file.
28 changes: 28 additions & 0 deletions 500 - Python style/ugly_module/ugly_exercise.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os

fileToDump = 'duped_class.json'

from random import randint

class SomeClass:
def __init__(self, ATTR1, attr2):
self.ATTR1 = ATTR1
self.attr2 = attr2

def printAttributes(self):
print(f'attrs: {self.ATTR1}, {self.attr2}')

class inheritedClass(SomeClass):
def printAttributes(self):
print(f"attrs: {self.attr2}, {self.ATTR1}")

def generate_int() -> str:
return randint(0, 10)

if __name__ == '__main__':
Number = generate_int()
classInstance = SomeClass(Number, 'other attribute')
classInstance.printAttributes()

subclassInstance = inheritedClass(Number, "other attribute")
subclassInstance.printAttributes()
6 changes: 3 additions & 3 deletions 510 - Requests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ print(curl.parse(response3))

#### Result:
```
curl -X POST -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'User-Agent: python-requests/2.28.0' -d 'title=t&body=b&userId=1' https://jsonplaceholder.typicode.com:443/posts
curl -X POST -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'User-Agent: python-requests/2.28.0' -d '{"title": "t", "body": "b", "userId": 1}' https://jsonplaceholder.typicode.com:443/posts
curl -X POST -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'Content-Type: application/json' -H 'User-Agent: python-requests/2.28.0' -d '{"title": "t", "body": "b", "userId": 1}' https://jsonplaceholder.typicode.com:443/posts
curl -X POST -H ... -H 'Content-Type: application/x-www-form-urlencoded' -H 'User-Agent: python-requests/2.28.0' -d 'title=t&body=b&userId=1' https://jsonplaceholder.typicode.com:443/posts
curl -X POST -H ... -H 'User-Agent: python-requests/2.28.0' -d '{"title": "t", "body": "b", "userId": 1}' https://jsonplaceholder.typicode.com:443/posts
curl -X POST -H ... -H 'Content-Type: application/json' -H 'User-Agent: python-requests/2.28.0' -d '{"title": "t", "body": "b", "userId": 1}' https://jsonplaceholder.typicode.com:443/posts
```

## Fake REST API [{JSON} Placeholder][]
Expand Down

0 comments on commit e115585

Please sign in to comment.