akamhy / waybackpy

Wayback Machine API interface & a command-line tool
https://pypi.org/project/waybackpy/
MIT License
484 stars 33 forks source link

Improve pylint score #142

Closed eggplants closed 2 years ago

eggplants commented 2 years ago
prev: 9.17/10 ``` ************* Module waybackpy waybackpy/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring) ************* Module waybackpy.wrapper waybackpy/wrapper.py:110:8: C0103: Attribute name "JSON" doesn't conform to snake_case naming style (invalid-name) waybackpy/wrapper.py:16:0: R0205: Class 'Url' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance) waybackpy/wrapper.py:16:0: R0902: Too many instance attributes (8/7) (too-many-instance-attributes) waybackpy/wrapper.py:74:4: R0913: Too many arguments (7/5) (too-many-arguments) waybackpy/wrapper.py:132:4: R0913: Too many arguments (6/5) (too-many-arguments) waybackpy/wrapper.py:66:8: W0201: Attribute 'wayback_machine_save_api' defined outside __init__ (attribute-defined-outside-init) waybackpy/wrapper.py:71:8: W0201: Attribute 'headers' defined outside __init__ (attribute-defined-outside-init) waybackpy/wrapper.py:110:8: W0201: Attribute 'JSON' defined outside __init__ (attribute-defined-outside-init) ************* Module waybackpy.cdx_api waybackpy/cdx_api.py:27:0: R0205: Class 'WaybackMachineCDXServerAPI' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance) waybackpy/cdx_api.py:27:0: R0902: Too many instance attributes (13/7) (too-many-instance-attributes) waybackpy/cdx_api.py:39:4: R0913: Too many arguments (11/5) (too-many-arguments) ************* Module waybackpy.cdx_snapshot waybackpy/cdx_snapshot.py:14:0: R0205: Class 'CDXSnapshot' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance) waybackpy/cdx_snapshot.py:14:0: R0902: Too many instance attributes (9/7) (too-many-instance-attributes) waybackpy/cdx_snapshot.py:14:0: R0903: Too few public methods (1/2) (too-few-public-methods) ************* Module waybackpy.save_api waybackpy/save_api.py:22:0: R0205: Class 'WaybackMachineSaveAPI' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance) waybackpy/save_api.py:22:0: R0902: Too many instance attributes (16/7) (too-many-instance-attributes) waybackpy/save_api.py:84:8: W0201: Attribute 'response' defined outside __init__ (attribute-defined-outside-init) waybackpy/save_api.py:86:8: W0201: Attribute 'headers' defined outside __init__ (attribute-defined-outside-init) waybackpy/save_api.py:87:8: W0201: Attribute 'status_code' defined outside __init__ (attribute-defined-outside-init) waybackpy/save_api.py:88:8: W0201: Attribute 'response_url' defined outside __init__ (attribute-defined-outside-init) waybackpy/save_api.py:132:8: W0201: Attribute 'response_url' defined outside __init__ (attribute-defined-outside-init) waybackpy/save_api.py:185:12: W0201: Attribute 'cached_save' defined outside __init__ (attribute-defined-outside-init) waybackpy/save_api.py:187:12: W0201: Attribute 'cached_save' defined outside __init__ (attribute-defined-outside-init) waybackpy/save_api.py:200:8: W0201: Attribute 'saved_archive' defined outside __init__ (attribute-defined-outside-init) waybackpy/save_api.py:208:12: W0201: Attribute 'saved_archive' defined outside __init__ (attribute-defined-outside-init) ************* Module waybackpy.cli waybackpy/cli.py:66:17: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) waybackpy/cli.py:211:0: R0913: Too many arguments (27/5) (too-many-arguments) waybackpy/cli.py:211:0: R0914: Too many local variables (42/15) (too-many-locals) waybackpy/cli.py:295:8: R0916: Too many boolean expressions in if statement (7/5) (too-many-boolean-expressions) waybackpy/cli.py:348:12: R1704: Redefining argument with the local name 'url' (redefined-argument-from-local) waybackpy/cli.py:211:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) waybackpy/cli.py:211:0: R0912: Too many branches (26/12) (too-many-branches) waybackpy/cli.py:211:0: R0915: Too many statements (68/50) (too-many-statements) ************* Module waybackpy.availability_api waybackpy/availability_api.py:58:8: C0103: Attribute name "JSON" doesn't conform to snake_case naming style (invalid-name) waybackpy/availability_api.py:40:0: R0205: Class 'WaybackMachineAvailabilityAPI' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance) waybackpy/availability_api.py:40:0: R0902: Too many instance attributes (11/7) (too-many-instance-attributes) waybackpy/availability_api.py:143:12: R0916: Too many boolean expressions in if statement (6/5) (too-many-boolean-expressions) waybackpy/availability_api.py:230:4: R0913: Too many arguments (7/5) (too-many-arguments) waybackpy/availability_api.py:112:8: W0201: Attribute 'response' defined outside __init__ (attribute-defined-outside-init) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.availability_api -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.wrapper -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.wrapper -> waybackpy.cdx_api -> waybackpy.cdx_utils -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.wrapper -> waybackpy.cdx_api -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.save_api -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0801: Similar lines in 2 files ==waybackpy.availability_api:[229:237] ==waybackpy.wrapper:[73:81] def near( self, year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, minute: Optional[int] = None, unix_timestamp: Optional[int] = None, (duplicate-code) waybackpy/availability_api.py:1:0: R0801: Similar lines in 2 files ==waybackpy.cli:[249:254] ==waybackpy.wrapper:[75:80] year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, minute: Optional[int] = None, (duplicate-code) ------------------------------------------------------------------ Your code has been rated at 9.17/10 (previous run: 8.34/10, +0.83) ```
after: 9.60/10 ``` ************* Module waybackpy.wrapper waybackpy/wrapper.py:18:0: R0902: Too many instance attributes (8/7) (too-many-instance-attributes) waybackpy/wrapper.py:79:4: R0913: Too many arguments (7/5) (too-many-arguments) waybackpy/wrapper.py:137:4: R0913: Too many arguments (6/5) (too-many-arguments) ************* Module waybackpy.cdx_api waybackpy/cdx_api.py:27:0: R0902: Too many instance attributes (13/7) (too-many-instance-attributes) waybackpy/cdx_api.py:39:4: R0913: Too many arguments (11/5) (too-many-arguments) ************* Module waybackpy.cdx_snapshot waybackpy/cdx_snapshot.py:14:0: R0902: Too many instance attributes (9/7) (too-many-instance-attributes) waybackpy/cdx_snapshot.py:14:0: R0903: Too few public methods (1/2) (too-few-public-methods) ************* Module waybackpy.save_api waybackpy/save_api.py:23:0: R0902: Too many instance attributes (16/7) (too-many-instance-attributes) ************* Module waybackpy.cli waybackpy/cli.py:211:0: R0913: Too many arguments (27/5) (too-many-arguments) waybackpy/cli.py:211:0: R0914: Too many local variables (43/15) (too-many-locals) waybackpy/cli.py:295:8: R0916: Too many boolean expressions in if statement (7/5) (too-many-boolean-expressions) waybackpy/cli.py:211:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) waybackpy/cli.py:211:0: R0912: Too many branches (26/12) (too-many-branches) waybackpy/cli.py:211:0: R0915: Too many statements (68/50) (too-many-statements) ************* Module waybackpy.availability_api waybackpy/availability_api.py:40:0: R0902: Too many instance attributes (11/7) (too-many-instance-attributes) waybackpy/availability_api.py:144:12: R0916: Too many boolean expressions in if statement (6/5) (too-many-boolean-expressions) waybackpy/availability_api.py:231:4: R0913: Too many arguments (7/5) (too-many-arguments) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.save_api -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.wrapper -> waybackpy.availability_api -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.availability_api -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0401: Cyclic import (waybackpy -> waybackpy.cdx_api -> waybackpy.cdx_utils -> waybackpy.utils) (cyclic-import) waybackpy/availability_api.py:1:0: R0801: Similar lines in 2 files ==waybackpy.availability_api:[230:238] ==waybackpy.wrapper:[78:86] def near( self, year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, minute: Optional[int] = None, unix_timestamp: Optional[int] = None, (duplicate-code) waybackpy/availability_api.py:1:0: R0801: Similar lines in 2 files ==waybackpy.cli:[249:254] ==waybackpy.wrapper:[80:85] year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, hour: Optional[int] = None, minute: Optional[int] = None, (duplicate-code) ------------------------------------------------------------------ Your code has been rated at 9.60/10 (previous run: 9.59/10, +0.02) ```
pep8speaks commented 2 years ago

Hello @eggplants! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 44:9: W503 line break before binary operator

Line 145:13: W503 line break before binary operator Line 146:13: W503 line break before binary operator Line 147:13: W503 line break before binary operator Line 148:13: W503 line break before binary operator Line 149:13: W503 line break before binary operator

Comment last updated at 2022-02-07 19:36:00 UTC
akamhy commented 2 years ago

From https://web.archive.org/save/https://github.com/akamhy/waybackpy:

Sorry This URL has been already captured 10 times today. Please email us at "info@archive.org" if you would like to discuss this more.

akamhy commented 2 years ago

headers:

TTP/2 429 Too Many Requests
server: nginx/1.19.5
date: Mon, 07 Feb 2022 19:46:17 GMT
content-type: text/html; charset=utf-8
cache-control: no-cache
x-app-server: wwwb-app52
x-ts: 429
x-tr: 20
x-rl: 0
x-na: 0
x-page-cache: MISS
x-nid: -
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
X-Firefox-Spdy: h2

429 doesn't always imply that we have hit 15 archives per minute, at least on my IP. It could also imply that the URL we are trying to archive has reached it maximum limit.

akamhy commented 2 years ago

Screenshot from 2022-02-08 01-21-19

eggplants commented 2 years ago

From https://web.archive.org/save/https://github.com/akamhy/waybackpy:

Sorry This URL has been already captured 10 times today. Please email us at "info@archive.org" if you would like to discuss this more.

I see for the first time...