Skip to content

Commit 8a330d8

Browse files
committed
updade from Atlas repo
1 parent c518bf8 commit 8a330d8

File tree

120 files changed

+2187
-1181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+2187
-1181
lines changed

03-dict-set/dialcodes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
print('d1:', d1.keys())
1818
d2 = dict(sorted(DIAL_CODES)) # <2>
1919
print('d2:', d2.keys())
20-
d3 = dict(sorted(DIAL_CODES, key=lambda x:x[1])) # <3>
20+
d3 = dict(sorted(DIAL_CODES, key=lambda x: x[1])) # <3>
2121
print('d3:', d3.keys())
2222
assert d1 == d2 and d2 == d3 # <4>
2323
# end::DIALCODES[]

03-dict-set/index.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# tag::INDEX[]
66
"""Build an index mapping word -> list of occurrences"""
77

8-
import sys
98
import re
9+
import sys
1010

1111
WORD_RE = re.compile(r'\w+')
1212

@@ -15,11 +15,11 @@
1515
for line_no, line in enumerate(fp, 1):
1616
for match in WORD_RE.finditer(line):
1717
word = match.group()
18-
column_no = match.start()+1
18+
column_no = match.start() + 1
1919
location = (line_no, column_no)
2020
index.setdefault(word, []).append(location) # <1>
2121

22-
# print in alphabetical order
22+
# display in alphabetical order
2323
for word in sorted(index, key=str.upper):
2424
print(word, index[word])
2525
# end::INDEX[]

03-dict-set/index0.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# tag::INDEX0[]
66
"""Build an index mapping word -> list of occurrences"""
77

8-
import sys
98
import re
9+
import sys
1010

1111
WORD_RE = re.compile(r'\w+')
1212

@@ -22,7 +22,7 @@
2222
occurrences.append(location) # <2>
2323
index[word] = occurrences # <3>
2424

25-
# print in alphabetical order
25+
# display in alphabetical order
2626
for word in sorted(index, key=str.upper): # <4>
2727
print(word, index[word])
2828
# end::INDEX0[]

03-dict-set/index_default.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# tag::INDEX_DEFAULT[]
66
"""Build an index mapping word -> list of occurrences"""
77

8-
import sys
9-
import re
108
import collections
9+
import re
10+
import sys
1111

1212
WORD_RE = re.compile(r'\w+')
1313

@@ -16,11 +16,11 @@
1616
for line_no, line in enumerate(fp, 1):
1717
for match in WORD_RE.finditer(line):
1818
word = match.group()
19-
column_no = match.start()+1
19+
column_no = match.start() + 1
2020
location = (line_no, column_no)
2121
index[word].append(location) # <2>
2222

23-
# print in alphabetical order
23+
# display in alphabetical order
2424
for word in sorted(index, key=str.upper):
2525
print(word, index[word])
2626
# end::INDEX_DEFAULT[]

04-text-byte/categories.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
import collections
3-
from unicodedata import name, category
3+
from unicodedata import category
44

55

66
def category_stats():
@@ -19,7 +19,7 @@ def category_scan(desired):
1919
for code in range(sys.maxunicode + 1):
2020
char = chr(code)
2121
if category(char) == desired:
22-
yield char
22+
yield char
2323

2424

2525
def main(args):
@@ -30,7 +30,7 @@ def main(args):
3030
count += 1
3131
if count > 200:
3232
break
33-
print()
33+
print()
3434
print(count, 'characters shown')
3535
else:
3636
counts, firsts = category_stats()

04-text-byte/default_encodings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import sys, locale
1+
import locale
2+
import sys
23

34
expressions = """
45
locale.getpreferredencoding()

04-text-byte/zwj_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
1F469 200D 2764 FE0F 200D 1F48B 200D 1F469 |kiss: woman, woman |E2.0
1111
"""
1212

13-
markers = {'\u200D': 'ZWG', # ZERO WIDTH JOINER
14-
'\uFE0F': 'V16', # VARIATION SELECTOR-16
15-
}
13+
markers = {'\u200D': 'ZWG', # ZERO WIDTH JOINER
14+
'\uFE0F': 'V16', # VARIATION SELECTOR-16
15+
}
1616

1717
for line in zwg_sample.strip().split('\n'):
1818
code, descr, version = (s.strip() for s in line.split('|'))

05-record-like/dataclass/coordinates.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313

1414
@dataclass(frozen=True)
1515
class Coordinate:
16-
1716
lat: float
1817
long: float
1918

2019
def __str__(self):
2120
ns = 'N' if self.lat >= 0 else 'S'
2221
we = 'E' if self.long >= 0 else 'W'
2322
return f'{abs(self.lat):.1f}°{ns}, {abs(self.long):.1f}°{we}'
24-
# end::COORDINATE[]
23+
# end::COORDINATE[]

08-def-type-hints/colors.py

-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,5 @@ def demo():
7676
print(n, name2hex(n, o))
7777

7878

79-
8079
if __name__ == '__main__':
8180
demo()

08-def-type-hints/columnize2.py

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def columnize(sequence: Sequence[T], num_columns: int = 0) -> List[Tuple[T, ...]
1010
return [tuple(sequence[i::num_rows]) for i in range(num_rows)]
1111

1212

13-
1413
def demo() -> None:
1514
nato = ('Alfa Bravo Charlie Delta Echo Foxtrot Golf Hotel India'
1615
' Juliett Kilo Lima Mike November Oscar Papa Quebec Romeo'
@@ -22,7 +21,6 @@ def demo() -> None:
2221
print(f'{word:15}', end='')
2322
print()
2423

25-
2624
print()
2725
for length in range(2, 21, 6):
2826
values = list(range(1, length + 1))

08-def-type-hints/columnize_alias.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def columnize(sequence: Sequence[str], num_columns: int) -> List[Row]:
1010
return [tuple(sequence[i::num_rows]) for i in range(num_rows)]
1111

1212

13-
1413
def demo() -> None:
1514
nato = ('Alfa Bravo Charlie Delta Echo Foxtrot Golf Hotel India'
1615
' Juliett Kilo Lima Mike November Oscar Papa Quebec Romeo'

08-def-type-hints/comparable/mymax_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Callable, TypeVar
1+
from typing import List, Callable
22

33
import pytest # type: ignore
44

08-def-type-hints/double/double_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ def test_double_nparray() -> None:
5353
def test_double_none() -> None:
5454
given = None
5555
with pytest.raises(TypeError):
56-
result = double(given)
56+
double(given)

08-def-type-hints/mode/mode_T.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def mode(data: Iterable[T]) -> T:
1212

1313

1414
def demo() -> None:
15-
from typing import List, Set, TYPE_CHECKING
15+
from typing import TYPE_CHECKING
1616
pop: list[set] = [set(), set()]
1717
m = mode(pop)
1818
if TYPE_CHECKING:
@@ -21,5 +21,6 @@ def demo() -> None:
2121
print(pop)
2222
print(repr(m), type(m))
2323

24+
2425
if __name__ == '__main__':
2526
demo()

08-def-type-hints/passdrill.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
"""passdrill: typing drills for practicing passphrases
44
"""
55

6-
import sys
76
import os
7+
import sys
8+
from base64 import b64encode, b64decode
89
from getpass import getpass
910
from hashlib import scrypt
10-
from base64 import b64encode, b64decode
11-
1211
from typing import Sequence, Tuple
1312

1413
HASH_FILENAME = 'passdrill.hash'
@@ -20,7 +19,7 @@ def prompt() -> str:
2019
confirmed = ''
2120
while confirmed != 'y':
2221
passphrase = input('Type passphrase to hash (it will be echoed): ')
23-
if passphrase == '' or passphrase == 'q':
22+
if passphrase in ('', 'q'):
2423
print('ERROR: the passphrase cannot be empty or "q".')
2524
continue
2625
print(f'Passphrase to be hashed -> {passphrase}')
@@ -45,7 +44,7 @@ def save_hash() -> None:
4544
salted_hash = build_hash(prompt())
4645
with open(HASH_FILENAME, 'wb') as fp:
4746
fp.write(salted_hash)
48-
print(f'Passphrase hash saved to', HASH_FILENAME)
47+
print(f'Passphrase hash saved to {HASH_FILENAME}')
4948

5049

5150
def load_hash() -> Tuple[bytes, bytes]:

08-def-type-hints/replacer2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FromTo(NamedTuple):
2020
to: str
2121

2222

23-
def zip_replace(text: str, changes: Iterable[FromTo], count:int = -1) -> str:
23+
def zip_replace(text: str, changes: Iterable[FromTo], count: int = -1) -> str:
2424
for from_, to in changes:
2525
text = text.replace(from_, to, count)
2626
return text

08-def-type-hints/romans.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
values_map = [
2-
(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1),
3-
( 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV','I')
2+
(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1),
3+
( 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I')
44
]
55

66
def to_roman(arabic: int) -> str:

08-def-type-hints/typeddict/books.py

-32
This file was deleted.

08-def-type-hints/typeddict/books_any.py

-32
This file was deleted.

08-def-type-hints/typeddict/demo_books.py

-20
This file was deleted.

08-def-type-hints/typeddict/demo_not_book.py

-23
This file was deleted.

0 commit comments

Comments
 (0)