René's URL Explorer Experiment


Title: [Mypy] fix other/least_recently_used by spazm · Pull Request #5814 · TheAlgorithms/Python · GitHub

Open Graph Title: [Mypy] fix other/least_recently_used by spazm · Pull Request #5814 · TheAlgorithms/Python

X Title: [Mypy] fix other/least_recently_used by spazm · Pull Request #5814 · TheAlgorithms/Python

Description: Describe your change: fix bug in dq_removal code. Needed to pass key to .remove() rather than index. remove incorrect annotation to make the __init__ an abstract function. Annotate all functions and class Generic[T] Expand example to show creating a LRUCache over concrete and mixed types. Adds doctest to LRUCache class Adds assert test in main. Previously opened as #5656 Closes: #4052 Before % git checkout master Your branch is up to date with 'origin/master'. % mypy --ignore-missing-imports --install-types least_recently_used.py least_recently_used.py:57: error: Cannot instantiate abstract class "LRUCache" with abstract attribute "__init__" Found 1 error in 1 file (checked 1 source file) % mypy --strict least_recently_used.py least_recently_used.py:27: error: Function is missing a type annotation least_recently_used.py:33: error: Unsupported right operand type for in ("object") least_recently_used.py:34: error: Argument 1 to "len" has incompatible type "object"; expected "Sized" least_recently_used.py:35: error: "object" has no attribute "pop" least_recently_used.py:36: error: "object" has no attribute "remove" least_recently_used.py:39: error: Need type annotation for "key" least_recently_used.py:39: error: Argument 1 to "enumerate" has incompatible type "object"; expected "Iterable[]" least_recently_used.py:43: error: "object" has no attribute "remove" least_recently_used.py:45: error: "object" has no attribute "appendleft" least_recently_used.py:46: error: "object" has no attribute "add" least_recently_used.py:48: error: Function is missing a return type annotation least_recently_used.py:48: note: Use "-> None" if function does not return a value least_recently_used.py:52: error: "object" has no attribute "__iter__"; maybe "__str__" or "__dir__"? (not iterable) least_recently_used.py:57: error: Cannot instantiate abstract class "LRUCache" with abstract attribute "__init__" least_recently_used.py:58: error: Call to untyped function "refer" in typed context least_recently_used.py:59: error: Call to untyped function "refer" in typed context least_recently_used.py:60: error: Call to untyped function "refer" in typed context least_recently_used.py:61: error: Call to untyped function "refer" in typed context least_recently_used.py:62: error: Call to untyped function "refer" in typed context least_recently_used.py:63: error: Call to untyped function "refer" in typed context least_recently_used.py:64: error: Call to untyped function "display" in typed context Found 20 errors in 1 file (checked 1 source file) After % git checkout mypy-fix-other-least_recently_used Switched to branch 'mypy-fix-other-least_recently_used' Your branch is up to date with 'origin/mypy-fix-other-least_recently_used'. % mypy --strict least_recently_used.py Success: no issues found in 1 source file Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Checklist: I have read CONTRIBUTING.md. This pull request is all my own work -- I have not plagiarized. I know that pull requests will not be merged if they fail the automated tests. This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms. All new Python files are placed inside an existing directory. All filenames are in all lowercase characters with no spaces or dashes. All functions and variable names follow Python naming conventions. All function parameters and return values are annotated with Python type hints. All functions have doctests that pass the automated testing. All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation. If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Open Graph Description: Describe your change: fix bug in dq_removal code. Needed to pass key to .remove() rather than index. remove incorrect annotation to make the __init__ an abstract function. Annotate all functions ...

X Description: Describe your change: fix bug in dq_removal code. Needed to pass key to .remove() rather than index. remove incorrect annotation to make the __init__ an abstract function. Annotate all functions ...

Opengraph URL: https://github.com/TheAlgorithms/Python/pull/5814

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:53a735e3-4bfb-0fb6-f387-60944931374f
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD0C2:351F5E:1FB4695:2B076EA:6A6555B0
html-safe-noncec9791d3923f6a2ce4392a97764cb5c6450b30507baaed253214ecd8e3ca1b5bd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEMyOjM1MUY1RToxRkI0Njk1OjJCMDc2RUE6NkE2NTU1QjAiLCJ2aXNpdG9yX2lkIjoiMTE5ODcyMDc3NDE4ODY1MTk1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac51e55ba297d04ac6fd8ecd88dde1dfe07cd8dcf5a538c39ab6780f72d637261e
hovercard-subject-tagpull_request:778129700
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
twitter:imagehttps://avatars.githubusercontent.com/u/92896?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/92896?s=400&v=4
og:image:altDescribe your change: fix bug in dq_removal code. Needed to pass key to .remove() rather than index. remove incorrect annotation to make the __init__ an abstract function. Annotate all functions ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/TheAlgorithms/Python git https://github.com/TheAlgorithms/Python.git
octolytics-dimension-user_id20487725
octolytics-dimension-user_loginTheAlgorithms
octolytics-dimension-repository_id63476337
octolytics-dimension-repository_nwoTheAlgorithms/Python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id63476337
octolytics-dimension-repository_network_root_nwoTheAlgorithms/Python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FTheAlgorithms%2FPython%2Fpull%2F5814%2Fcommits%2F77e4209a7e9e8328279b705e280d77bee404b775
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FTheAlgorithms%2FPython%2Fpull%2F5814%2Fcommits%2F77e4209a7e9e8328279b705e280d77bee404b775
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=TheAlgorithms%2FPython
Reloadhttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
Reloadhttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
Reloadhttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
Please reload this pagehttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
TheAlgorithms https://github.com/TheAlgorithms
Pythonhttps://github.com/TheAlgorithms/Python
Please reload this pagehttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
Notifications https://github.com/login?return_to=%2FTheAlgorithms%2FPython
Fork 50.9k https://github.com/login?return_to=%2FTheAlgorithms%2FPython
Star 223k https://github.com/login?return_to=%2FTheAlgorithms%2FPython
Code https://github.com/TheAlgorithms/Python
Issues 144 https://github.com/TheAlgorithms/Python/issues
Pull requests 877 https://github.com/TheAlgorithms/Python/pulls
Discussions https://github.com/TheAlgorithms/Python/discussions
Actions https://github.com/TheAlgorithms/Python/actions
Projects https://github.com/TheAlgorithms/Python/projects
Wiki https://github.com/TheAlgorithms/Python/wiki
Security and quality 0 https://github.com/TheAlgorithms/Python/security
Insights https://github.com/TheAlgorithms/Python/pulse
Code https://github.com/TheAlgorithms/Python
Issues https://github.com/TheAlgorithms/Python/issues
Pull requests https://github.com/TheAlgorithms/Python/pulls
Discussions https://github.com/TheAlgorithms/Python/discussions
Actions https://github.com/TheAlgorithms/Python/actions
Projects https://github.com/TheAlgorithms/Python/projects
Wiki https://github.com/TheAlgorithms/Python/wiki
Security and quality https://github.com/TheAlgorithms/Python/security
Insights https://github.com/TheAlgorithms/Python/pulse
Sign up for GitHub https://github.com/signup?return_to=%2FTheAlgorithms%2FPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FTheAlgorithms%2FPython%2Fissues%2Fnew%2Fchoose
cclausshttps://github.com/cclauss
TheAlgorithms:masterhttps://github.com/TheAlgorithms/Python/tree/master
spazm:mypy-fix-other-least_recently_usedhttps://github.com/spazm/Python/tree/mypy-fix-other-least_recently_used
Conversation 1 https://github.com/TheAlgorithms/Python/pull/5814
Commits 18 https://github.com/TheAlgorithms/Python/pull/5814/commits
Checks 0 https://github.com/TheAlgorithms/Python/pull/5814/checks
Files changed https://github.com/TheAlgorithms/Python/pull/5814/files
Please reload this pagehttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
[Mypy] fix other/least_recently_used https://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775#top
Show all changes 18 commits https://github.com/TheAlgorithms/Python/pull/5814/files
7a6f9b8 makes LRUCache constructor concrete spazm Oct 29, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/7a6f9b87d7666b9c0332db9a224caa46b62b0e56
f95854f fixes bug in dq_removal in other/least_recently_used spazm Oct 29, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/f95854f9ae64fa16c1591f0ef47634676e0f4166
0b1334c [mypy] Annotates other/least_recently_used over generic type spazm Oct 29, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/0b1334c1196f30b46bb9ef4d27ed065dc924bb9f
77e4209 [mypy] updates example to demonstrate LRUCache with complex type spazm Oct 29, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
ec878d9 Adds doctest to other/least_recently_used spazm Oct 29, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/ec878d9f8b908a4c1fe04c186a7bb9d52066cd87
2fd99ca mypy.ini: Remove exclude = (other/least_recently_used.py) cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/2fd99ca9212cb76116f69d814a40fcf054890e31
d7cdb96 Various mypy configs cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/d7cdb96d2433bfbe7ef2f1e433a49896a21b347f
eb9a038 Delete mypy.ini cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/eb9a038b697341b2f0458b937bd98038d1e97e1b
e9d83ac Add mypy to .pre-commit-config.yaml cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/e9d83aca09410e1420e5df41636739567a9cdec0
ab28a5e mypy --ignore-missing-imports --install-types --non-interactive . cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/ab28a5ee9578e8693f6d7f3d20fb42fd8b8b8a02
14e8583 mypy v0.910 cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/14e8583394f4e6ee345e1fa45f86421a71b03ad7
c136814 Pillow=8.3.7 cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/c13681402dc26706b6bc02d1bc46e25f55d9e12c
f7aab7d Pillow==8.3.7 cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/f7aab7d9764d220db1fc0916446074301fc9a4b4
17f3054 Pillow==8.3.2 cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/17f3054f0302822d22c554479654d4df764e4eed
1a188cc Update .pre-commit-config.yaml cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/1a188cc9f30b0e9a0d03bf0c2911f70a7b7a8ef8
4b1cd7b Update requirements.txt cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/4b1cd7b783a9fa82bec07fa06bda67d5fdee3a6c
ab109ef Update pre-commit.yml cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/ab109efa5e8f692ee722c4d20766f79c93ec6c12
6065956 --install-types # See mirrors-mypy README.md cclauss Nov 16, 2021 https://github.com/TheAlgorithms/Python/pull/5814/commits/60659568314644c37a7f63188c0d76712f45dba4
Clear filters https://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
Please reload this pagehttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
Please reload this pagehttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
Prev https://github.com/TheAlgorithms/Python/pull/5814/commits/0b1334c1196f30b46bb9ef4d27ed065dc924bb9f
Next https://github.com/TheAlgorithms/Python/pull/5814/commits/ec878d9f8b908a4c1fe04c186a7bb9d52066cd87
Please reload this pagehttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775
https://github.com/spazm
spazmhttps://github.com/TheAlgorithms/Python/commits?author=spazm
other/least_recently_used.pyhttps://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775#diff-cc3fe4dcf7c506372bad7350a1e5da16c562e2fea97569864ddbf2854a7ca554
View file https://github.com/spazm/Python/blob/77e4209a7e9e8328279b705e280d77bee404b775/other/least_recently_used.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/TheAlgorithms/Python/pull/5814/commits/{{ revealButtonHref }}
https://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775#diff-cc3fe4dcf7c506372bad7350a1e5da16c562e2fea97569864ddbf2854a7ca554
https://github.com/TheAlgorithms/Python/pull/5814/commits/77e4209a7e9e8328279b705e280d77bee404b775#diff-cc3fe4dcf7c506372bad7350a1e5da16c562e2fea97569864ddbf2854a7ca554
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.