jay3332 / pilmoji

Pilmoji is a fast and reliable emoji renderer for PIL.
MIT License
77 stars 28 forks source link

Update Depreciated Pillow Methods #19

Closed vertyco closed 2 years ago

vertyco commented 2 years ago

Using latest pillow antialias method Resampling.LANCZOS Using latest pillow getsize method getlength

sourcery-ai[bot] commented 2 years ago

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 2.34%.

Quality metrics Before After Change
Complexity 7.80 ⭐ 9.43 🙂 1.63 👎
Method Length 75.00 🙂 76.88 🙂 1.88 👎
Working memory 11.44 😞 11.83 😞 0.39 👎
Quality 60.62% 🙂 58.28% 🙂 -2.34% 👎
Other metrics Before After Change
Lines 422 433 11
Changed files Quality Before Quality After Quality Change
pilmoji/core.py 58.77% 🙂 57.10% 🙂 -1.67% 👎
pilmoji/helpers.py 65.54% 🙂 61.33% 🙂 -4.21% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
pilmoji/core.py Pilmoji.text 21 😞 313 ⛔ 23 ⛔ 20.42% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
pilmoji/helpers.py getsize 15 🙂 117 🙂 15 😞 44.82% 😞 Extract out complex expressions
pilmoji/core.py Pilmoji.__init__ 4 ⭐ 134 😞 14 😞 54.10% 🙂 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

vertyco commented 2 years ago

I've implemented this if you think it will suffice, since getsize was depreciated in 9.2

                if PIL.__version__ >= "9.2.0":
                    width = font.getlength(content)
                else:
                    width, _ = font.getsize(content)
vertyco commented 2 years ago

making all the necessary adjustments and reopening this