TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #397 · 12 ное.

Использование Pydantic сегодня стало нормой, и это правильно. Но иногда на ревью вижу, что используют его не всегда корректно. Например, метод BaseModel.model_dump() по умолчанию не преобразует стандартные типы, такие как datetime, UUID или Decimal, в простой сериализуемый для JSON вид. Тогда пишут кастмоный сериализатор для этих типов чтобы функция json.dump() не падала с ошибкой. import uuid from datetime import datetime from decimal import Decimal from uuid import UUID from pydantic import BaseModel class MyModel(BaseModel): id: UUID date: datetime value: Decimal obj = MyModel( id=uuid.uuid4(), date=datetime.now(), value='1.23' ) print(obj.model_dump()) # не подходит для json.dump # { # 'id': UUID('4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1'), # 'date': datetime.datetime(2025, 12, 12, 12, 12, 12, 111111), # 'value': Decimal('1.23') # } # добавляем свой кастомный сериализатор json.dumps(obj.model_dump(), cls=MySerializer) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2025-12-12T12:12:12.111111', # 'value': '1.23' # } В данном случае класс MySerializer обрабатывает datetime, UUID и Decimal. Например так: class MySerializer(json.JSONEncoder): def default(self, o): if isinstance(o, Decimal): return str(o) elif isinstance(o, datetime): return o.isoformat() elif isinstance(o, UUID): return str(o) return super().default(o) Специально для тех, кто всё еще так делает - в этом нет необходимости! Pydantic может это сделать сам, просто нужно добавить параметр mode="json". json.dumps(obj.model_dump(mode="json")) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2012-12-12T12:12:12.111111', # 'value': '1.23' # } #pydantic#libs

Резултати

Пронајдени 1 слични објави

Пребарај: #mssqlserver

当前筛选 #mssqlserver清除筛选
MDC Uzbekistan

@mdcuzbekistan · Post #227 · 26.11.2021 г., 09:44

#dotnet#middle#MSSQLserver Applied Labs is looking for a .Net Developer Salary: $1500-3000 Location: 100% remote job, but we have an office in Tashkent, if you feel comfortable working from the office. All stages of recruitment are carried out remotely by calling a video (Zoom). You will need to have: - Proficiency in C #, .NET Framework and .NET Core; - Understanding how web protocols (HTTP, HTTPS) and REST / SOAP API work; - Knowledge of MS SQL Server, Oracle, PostgreSQL: the ability to design a database structure, write and optimize SQL queries and stored procedures; - 3+ years of work experience; - Fluency in English (verbal and written communication); - Bachelor's Degree in Computer Science, Engineering or related field or strong track record proving the equivalent level of experience; - Capability to multi-task with strong attention to detail; - Ability to work in a fast-paced, agile environment and resolving unplanned incidents quickly; - Outstanding communication skills, including the ability to effectively present information in both technical and non-technical terms and train users using non-technical terms; - Strong customer service focus; - Excellent team player skills with the ability to influence others. It would be an added bonus if you have: - Azure, Azure DevOps ; - M365 is a huge plus; - Jira and Confluence; - MS Graph API’s. We would love to see: - A sound knowledge of software engineering; - Excellent analytical skills; - Sourcing requirements from customers and suggesting appropriate solutions; - Quick generating of POC (proof of concepts) and demos; - Self-motivated, proactive, independent & responsive candidate, the specialist, who requires little supervisory attention We offer: - Flexible office policy - You can work from wherever you want or from our cozy office in Tashkent. You can even combine both - few days in the office and a few days remote; - 5/2 work week, 8 hours a day (you are expected to be available for communication between 18:00 to 23:00 Tashkent time, as you'll be working with the US team located in New York); - Official employment in accordance with Uzbekistan's Labor Laws; - Frequent team-building activities and internal hackathons; - Health insurance; - English courses; - Group exercises; - Reimbursement for sport. Send an email with your resume in English and the subject line "Data Engineer" to [email protected] To apply for this position, please feel out the application form here: https://appliedlabs.pinpointhq.com/en/jobs/32045 👉Подписаться на канал @UzDev_Jobs