blikenoother / aiourlshortener

aiourlshortener is a asyncio python3 compatible library for URL shorting using Googl, Bitly API
MIT License
3 stars 1 forks source link

Code cleanup #6

Open das7pad opened 6 years ago

das7pad commented 6 years ago

These lines / instance attributes remain unused in the code:

And one more thing:

What were your thoughts to allow an actual derived BaseShortener (let's call it Demo) as the engine argument for a Shortener? One could simply create an instance of Demo and use the api of it?

blikenoother commented 6 years ago
das7pad commented 6 years ago

https://github.com/blikenoother/aiourlshortener/blob/fee8d34f5fa0e91579a5f1d8f61487894e8deb63/aiourlshortener/shorteners/__init__.py#L88

await asyncio.gather(shortener.short('https://github.com/'),
                     shortener.short('https://github.com/blikenoother/aiourlshortener/'),
                     return_exceptions=True)

shortener.shorten can now store a short-url for 'https://github.com/' or one for 'https://github.com/blikenoother/aiourlshortener/'. It may also be None in case both short calls failed.

The point is that shortener.shorten does not store a predictable content.


https://github.com/blikenoother/aiourlshortener/blob/fee8d34f5fa0e91579a5f1d8f61487894e8deb63/aiourlshortener/shorteners/__init__.py#L40 It is a calculated value and the user knows the content of it as he used it for the init. This one can be refactored in a property decorated function.


What were your thoughts to allow an actual derived BaseShortener (let's call it Demo) as the engine argument for a Shortener? One could simply create an instance of Demo and use the api of it?

We could refactor Shortener into a function which returns a derived BaseShortener instance. There is no need to copy the public api of BaseShortener.

blikenoother commented 6 years ago


We could refactor Shortener into a function which returns a derived BaseShortener instance. There is no need to copy the public api of BaseShortener.

can you pls explain this with sample code?

das7pad commented 6 years ago

can you pls explain this with sample code?

https://github.com/das7pad/aiourlshortener/tree/refactor-shortener-class